Welcome to dbFreaks.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

SQLConfigDataSource - Defining the 'lpszAttributes' from A..

 
   Database Help (Home) -> Visual Basic -> ODBC RSS
Next:  VB newby questions Access and VB  
Author Message
Semtex

External


Since: Jan 09, 2004
Posts: 2



(Msg. 1) Posted: Fri Jan 09, 2004 11:43 am
Post subject: SQLConfigDataSource - Defining the 'lpszAttributes' from Acc
Archived from groups: microsoft>public>vb>database>odbc (more info?)

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.

 >> Stay informed about: SQLConfigDataSource - Defining the 'lpszAttributes' from A.. 
Back to top
Login to vote
Display posts from previous:   
   Database Help (Home) -> Visual Basic -> ODBC All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]