Siby Sunny
Siby Sunny

Reputation: 752

Remote DB connection string failed

I need to connect the db on another system. while i tried the connection string as

SqlConnection con = new SqlConnection(@"Data Source=(192.168.0.125)\SQLEXPRESS,1433;Network Library=DBMSSOCN;Initial Catalog=db_Stock;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False";

error shown:

"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - No such host is known.)"

Upvotes: 0

Views: 842

Answers (3)

Siby Sunny
Siby Sunny

Reputation: 752

i fixed the issue by following the below site and instructions

link to the site]site

Upvotes: 0

Adil Ansari
Adil Ansari

Reputation: 356

You need to create a database user for remote connection, and pass them in your web.config file.

Also you need to set Integrated security=false. According to [Microsoft][1]

When false, User ID and Password are specified in the connection. When true, the current Windows account credentials are used for authentication. Recognized values are true, false, yes, no, and sspi (strongly recommended), which is equivalent to true.

Example: (192.168.0.125)\SQLEXPRESS,1433;Network Library=DBMSSOCN;Initial Catalog=db_Stock;Integrated Security=True;user id=sa;password=sa123;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"

Upvotes: 0

User2012384
User2012384

Reputation: 4919

You don't need the brackets

Data Source=192.168.0.125\SQLEXPRESS,1433;Network Library=DBMSSOCN;Initial Catalog=db_Stock;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False

ConnectionStrings

Upvotes: 3

Related Questions