Wednesday, December 9, 2015

Blank "initial catalog" problem on OLEDB connection string of SQL Server Database

see also -- Got Error: Invalid object name 'master.dbo.spt_values'

As usually we use below connection string to connect to SQL Server using OLEDB provider.

Data Source=DBSERVER;Initial Catalog=DB_NAME;Provider=SQLNCLI10.1;Integrated Security=SSPI;Persist Security Info=False;

What if “Initial Catalog” is blank like below one?

Data Source=DBSERVER;Initial Catalog=;Provider=SQLNCLI10.1;Integrated Security=SSPI;Persist Security Info=False;

We know when we create a login user; we have to mansion a database as default to connect. Due to this, OLEDB provider connects to this default database in case of missing Initial Catalog. So that we have to more careful to run DDL using OLEDB.

To bypass this default fault/mistake, we can create a dummy blank database and point all users to this blank database as default database.

No comments:

Post a Comment