Issue creating sql authentication odbc system dsn

Issue creating sql authentication odbc system dsn

Post by mat » Thu, 11 Mar 2010 12:01:37


Can anyone spot what's wrong with the code below which attempts to
create a system dsn using sql server authentication? The login id and
password are good for sure so is the db name and server name.

Private Declare Function SQLConfigDataSource Lib "odbccp32.dll" _
(ByVal hwndParent As Long, _
ByVal fRequest As Integer, _
ByVal lpszDriver As String, _
ByVal lpszAttributes As String) As Long

public CreateDSN()

dim lngResult as long
' skip stuff
lngResult = SQLConfigDataSource(0, _
ODBC_ADD_SYS_DSN, _
"SQL Native Client", _
"DSN=mydsn" & & Chr(0) & _
"Server=" & strServerName & Chr(0) & _
"Database=mydb" & Chr(0) & _
"Trusted_Connection=No" & Chr(0) & _
"Uid=sql_login" & Chr(0) & _
"Pwd=secret" & Chr(0) & Chr(0))
'lngResult is always 0.
End function

The system dsn 'mydsn' does not exist. Windows xp, Access 2003, sql
server 2005.
 
 
 

Issue creating sql authentication odbc system dsn

Post by mat » Thu, 11 Mar 2010 12:43:27

Found a good way to create a system dsn at

http://www.yqcomputer.com/

Still curious to know why the code below failed, if anyone can spot it.

In article < XXXX@XXXXX.COM >,
XXXX@XXXXX.COM says...