Search code examples
.netsql-server-2005oledbconnection-string

What does it mean if I don't provide an InitialCatalog in a OLEDB connection string?


I have a connection string (to an SQLServer 2005 database) which specifies a server, username and password, but does not specify an InitialCatalog. When I try and open connection it works, and I can list the tables, which lists a lot of tables, but not the table from the database I am interested in.

What is it I am connected to when no InitialCatalog is specified. Why is it valid?


Solution

  • If you do not specify the database, the default, as configured for the user will be used.

    You can issue a "Use DatabaseName" statement to switch databases.

    You can view the default database by looking at the properties of the user account. By default I believe it is the "master" database.