I want to connect to a remote database (SQL Server 2008) through code using a connection string. But I am not be able to connect to it. But I can connect the database using the SQL Server Management Studio successfully, using SQL Server authentication.
But whenever I am trying using code I am getting the exception like::
[DBNETLIB][ConnectionOpen (Invalid Instance()).]Invalid connection.
My connection string is like this ::
Data Source=192.x.x.x;Initial Catalog=mydbName;User ID=user;Password=passw;provider=SQLOLEDB
Can anybody help me out.
thanks in advance.
You don’t show the C# code you’re using to connect – but I think the problem is the provider. If ever possible – use the native SQL client interface from the
System.Data.SqlClientassembly to connect to SQL Server.Can you try this connection string instead:
In your config:
And then use this code snippet:
See the Connection Strings web site for tons of examples of valid connection strings and what all those options mean.