Thursday, March 29, 2012

DSN goes to wrong database

Hello!

I set up a system DSN but it connects to the wrong database. I have set the default database correctly but it seems to ignore it.

If i switch to the correct BD like this: "USE myDB SELECT * FROM myTable" then it works fine.

Am i missing something?

this is my connection string [in my ASP page]:

"Driver={SQL Server};" &_
"Server=myServer;" &_
"DSN=myDSN;" &_
"UID=myUserName;" &_
"PWD=myPWD;"

Thanks!What database is it defaulting to ?|||Looks like you're mixing up the ODBC connect string data. Use one of these formats

To use the System DSN you created use
"Driver={SQL Server};" &_
"DSN=myDSN;" &_
"UID=myUserName;" &_
"PWD=myPWD;"
(may or maynot work)

To use a DSNless connection use
"Driver={SQL Server};" &_
"Database=myDB;" &_
"UID=myUserName;" &_
"PWD=myPWD;"
(Should work, but haven't tested)

I'm thinking it's probably trying to use the user's default database set up in SQL Server. Your alternative would be to go into use manager and change the default db (or tell your DBA to do it).

Originally posted by rnealejr
What database is it defaulting to ?|||yeah i think it has something to do with the particular user. a different username and password will change the default database.

i'll try that connection string. thank you!

the problem is i am the DBA at the moment. the ususal guy is away for awhile.

No comments:

Post a Comment