Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to programmatically create System DSN for VFP

Status
Not open for further replies.

jkentakgyris

Programmer
May 12, 2004
5
0
0
US
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)?

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 *********
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top