G
Gabriel Carulias
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
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