jkentakgyris
Programmer
Greetings! Hope it's the right forum as VB forum could not help.
It is a simple step to programmatically create a system DSN for SQL Server in VB6 (code below).
Does anyone know how to create a System DSN for a Microsoft FoxPro VFP Driver (*.dbf) with a free table directory (No database, No server) in VB6?
TIA!
******************************** CODE ********
DataSourceName = "mySQL"
Description = ""
DriverPath = "C:\WINNT\SYSTEM32\"
DatabaseName = "MBA"
LastUser = "Admin"
Server = "EAGLE"
DriverName = "SQL Server"
'Create the new DSN key.
lResult = RegCreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\ODBC\ODBC.INI\" & _
DataSourceName, hKeyHandle)
frmStart.lbxLog.AddItem ("Creating DSN key for " + strName)
'Set the values of the new DSN key.
lResult = RegSetValueEx(hKeyHandle, "Database", 0&, REG_SZ, _
ByVal DatabaseName, Len(DatabaseName))
lResult = RegSetValueEx(hKeyHandle, "Description", 0&, REG_SZ, _
ByVal Description, Len(Description))
lResult = RegSetValueEx(hKeyHandle, "Driver", 0&, REG_SZ, _
ByVal DriverPath, Len(DriverPath))
lResult = RegSetValueEx(hKeyHandle, "LastUser", 0&, REG_SZ, _
ByVal LastUser, Len(LastUser))
lResult = RegSetValueEx(hKeyHandle, "Server", 0&, REG_SZ, _
ByVal Server, Len(Server))
'Close the new DSN key.
lResult = RegCloseKey(hKeyHandle)
**************************** END CODE *********
It is a simple step to programmatically create a system DSN for SQL Server in VB6 (code below).
Does anyone know how to create a System DSN for a Microsoft FoxPro VFP Driver (*.dbf) with a free table directory (No database, No server) in VB6?
TIA!
******************************** CODE ********
DataSourceName = "mySQL"
Description = ""
DriverPath = "C:\WINNT\SYSTEM32\"
DatabaseName = "MBA"
LastUser = "Admin"
Server = "EAGLE"
DriverName = "SQL Server"
'Create the new DSN key.
lResult = RegCreateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\ODBC\ODBC.INI\" & _
DataSourceName, hKeyHandle)
frmStart.lbxLog.AddItem ("Creating DSN key for " + strName)
'Set the values of the new DSN key.
lResult = RegSetValueEx(hKeyHandle, "Database", 0&, REG_SZ, _
ByVal DatabaseName, Len(DatabaseName))
lResult = RegSetValueEx(hKeyHandle, "Description", 0&, REG_SZ, _
ByVal Description, Len(Description))
lResult = RegSetValueEx(hKeyHandle, "Driver", 0&, REG_SZ, _
ByVal DriverPath, Len(DriverPath))
lResult = RegSetValueEx(hKeyHandle, "LastUser", 0&, REG_SZ, _
ByVal LastUser, Len(LastUser))
lResult = RegSetValueEx(hKeyHandle, "Server", 0&, REG_SZ, _
ByVal Server, Len(Server))
'Close the new DSN key.
lResult = RegCloseKey(hKeyHandle)
**************************** END CODE *********