Search code examples
c#oledb

OleDBConnection Error in C#


I am using C# to connect to my MS SQL database with OleDBConnection. I can log in successfully by SSMS, but not by OleDBConnection.

I get an exception such as:

[DBNETLIB][ConnectionOpen (Invalid Instance()).] Invalid connection.

Below is my connection string:

Provider=SQLOLEDB.1;Pemmrsist Security Info=True;Data Source=127.0.0.1;Initial Catalog=Test_DB;User ID=test;Pwd=testdb;Connect Timeout=15

and I have added the test login.


Solution

  • I've enabled TCP/IP and I add port 1433, so I modify my connection IP to 127.0.0.1,1433. Then, it worked.