Reputation: 752
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
Reputation: 752
i fixed the issue by following the below site and instructions
link to the site]site
Upvotes: 0
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
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
Upvotes: 3