SQLConfigDataSource - Defining the 'lpszAttributes' from Access (vba) to SQL 2K

This is a discussion on SQLConfigDataSource - Defining the 'lpszAttributes' from Access (vba) to SQL 2K within the ODBC forums in Framework and Interface Programming category; 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 ...

Go Back   Application Development Forum > Framework and Interface Programming > ODBC

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 01-09-2004, 11:43 AM
Semtex
Guest
 
Default SQLConfigDataSource - Defining the 'lpszAttributes' from Access (vba) to SQL 2K

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.
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 06:53 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.