Hello friends, I have a problem. I hope that you can help me.
My problem is that I need to create a connection ODBC in run-time. The
application is an Access file that runs a VB code. The code that I run is:
#If Win32 Then
Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" _
(ByVal hwndParent As Long, ByVal fRequest As Long, _
ByVal lpszDriver As String, ByVal lpszAttributes As String) _
As Long
#Else
Private Declare Function SQLConfigDataSource Lib "ODBCINST.DLL" _
(ByVal hwndParent As Integer, ByVal fRequest As Integer, ByVal _
lpszDriver As String, ByVal lpszAttributes As String) As Integer
#End If
strAttributes = "DATABASE=" & strDatabaseName & Chr$(0)
strAttributes = strAttributes & "DESCRIPTION=" & strDescription & Chr$(0)
strAttributes = strAttributes & "DSN=" & strDataSourceName & Chr$(0)
strAttributes = strAttributes & "SERVER=" & strServer & Chr$(0)
‘If I put the 2 line below, not generate the connection, and I need that the
connection has a user Id and password
strAttributes = strAttributes & "UID=" & strUID & Chr$(0)
strAttributes = strAttributes & "PWD=" & strPwd & Chr$(0)
intRet = SQLConfigDataSource(vbAPINull, ODBC_ADD_DSN, strDriver,
strAttributes)
Thank you, and if you need everything please tell me
Douglas J. Steele - 20 Dec 2005 11:59 GMT
Why not go DSN-less? I have an example of one way to do this at
http://www.accessmvp.com/djsteele/DSNLessLinks.html
You may have to check Carl Prothman's site
http://www.carlprothman.net/Default.aspx?tabid=90 to ensure you're using the
correct connection string.

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
> Hello friends, I have a problem. I hope that you can help me.
> My problem is that I need to create a connection ODBC in run-time. The
[quoted text clipped - 26 lines]
>
> Thank you, and if you need everything please tell me