Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / December 2005

Tip: Looking for answers? Try searching our database.

Connection with ODBC

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gabriel Carulias - 20 Dec 2005 09:53 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.