Hi!I’m trying to creata a ODBC Data Source in code and I did find the code below here in the forum…
Does anyone know how I shall change the code to create a ODBC-connection using Client Acces ODBC Driver?
Also, does anyone know if there is a way to, in code, check if the Data Source already exist?
Thanks in advance.
/Jocke
Declare Function SQLConfigDataSource Lib “ODBCCP32.DLL” (Byval hwndParent As Long, _
Byval fRequest As Long, _
Byval lpszDriver As String, _
Byval lpszAttributes As String) As Long
Const ODBC_ADD_DSN = 1 ’ Add data source
Const ODBC_CONFIG_DSN = 2 ’ Configure (edit) data source
Const ODBC_REMOVE_DSN = 3 ’ Remove data source
dbAttributes = “COLLATINGSEQUENCE=ASCII”+Chr$(0)+_
“DEFAULTDIR=”+[some path here]+Chr$(0)+_
“DELETED=0”+Chr$(0)+_
“DSN=”+[Some string here]+Chr$(0)+_
“DESCRIPTION=”+[some string here]+Chr$(0)+_
“DRIVERID=277”+Chr$(0)+_
“FIL=dBase IV”+Chr$(0)+_
“PAGETIMEOUT=600”+Chr$(0)+_
“READONLY=False”
flag = SQLConfigDataSource(0, ODBC_ADD_DSN, “Microsoft dBase Driver (*.dbf)”, dbAttributes)