Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ODBC default database

Status
Not open for further replies.

scc

Programmer
Apr 30, 2001
218
US
I'm curious... I just changed jobs, so new questions come up.

Anyway, here's my question:

If you create a new ODBC connection and name it the same name as your database and then do not click on the checkbox for "change the default database to", does the ODBC use the ODBC data source name as the default database connection?

Hope that makes sense. In my previous position, we always named the ODBC the same name at the database it was to connect to, and never had to check the default connection checkbox. Is that why?

TIA!
 
Not really. Here's what happens:

1. You create a LOGIN to SQL Server and give it a default database (In EM drill down to Security and click on Logins. Then click on a login and you will see the area for the default database.)
2. You create an ODBC connection. The default database for the connection is the same as the login being used (which was created in step 1).

So, when you create/use an ODBC connection...it first checks the login/password against SQL Server. If it has access to SQL, then it needs to find out which database to go to. It first checks itself (the ODBC connection) to see if you 'overrode' the SQL Server default database. If not, then it asks SQL Server which database is to be used.

-SQLBill
 
Thanks for responding, but this confuses me even more...

We had several SQL Servers and many databases (not tables) on each one. It didn't matter which database we wanted to create the ODBC driver for, we never gave it a default database name and it always connected to the right database, which happened to be the one that was the 'name' given to the ODBC driver. So how did it know to use the correct one (since they all couldn't be a default for that particular SQL Server)?

Just trying to understand...
 
Unless your admin was doing something you don't know about or the program was modifying the DSN based on it's name (it could even be overriding the database name when it does the open without changing the DSN) - you must supply the database you want to use - otherwise as SQLBill said above, it will use the default database for the user (assuming Windows/Integrated security) is being used.

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top