Create ODBC Data Source

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)

Subject: Create ODBC Data Source - Solved!

I did solve the problem. To check if the Source already exist I check the ODBC.ini file.

dbAttributes = “description=[Description]”+Chr$(0)+“system=[System name]”+Chr$(0)+

“DSN=[Name of Data Source]”+Chr$(0)+_

“DBQ=[Name of library]”+Chr$(0)+_

“Translate=1”+Chr$(0)

flag = SQLConfigDataSource(0, ODBC_ADD_DSN, “Client Access ODBC Driver (32-bit)”, dbAttributes)