Issue creating sql authentication odbc system dsn

M

mat

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top