| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| I am having some issues trying to exploit the above function wrt. the attributes and how to define them from some VBA code. I have hunted through various Newsgroups, MSDN Areas and Websites, it appears to be fully discussed but I still can't use all the attributes. I am using the following code called with parameters from another function:- ------------------------------------------------------------------- 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 Const ODBC_ADD_SYS_DSN = 4 'Add data source ------------------------------------------------------------------- Public Function CreateSQLServerDSN(DSNName As String, ServerName As String, Database As String, User As String, Password As String) As Boolean Dim sAttributes As String sAttributes = "DSN=" & DSNName & Chr(0) sAttributes = sAttributes & "Server=" & ServerName & Chr(0) sAttributes = sAttributes & "Database=" & Database & Chr(0) sAttributes = sAttributes & "Description=VSS - " & DSNName & Chr(0) sAttributes = sAttributes & "UID=" & User & Chr(0) sAttributes = sAttributes & "PWD=" & Password & Chr(0) & Chr(0) CreateSQLServerDSN = CreateDSN("SQL Server", sAttributes) End Function ------------------------------------------------------------------- Public Function CreateDSN(Driver As String, Attributes As String) As Boolean CreateDSN = SQLConfigDataSource(0, ODBC_ADD_SYS_DSN, Driver, Attributes) End Function ------------------------------------------------------------------- If I strip off the UID & PWD elements of the sAttributes string it works, if I leave either of them in plave it fails to create a System DSN. Another issue I was hoping to cure was the ability to set the Authentication method whilst the System DSN was being created, can this be done? I appreciate any assistance, guidance, weblinks or samples that may be lurking around out there. Thank you in advance. |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.