Writing a connection string to access a remote SQL Server database

My database is hosted on a remote server. I need to write a connection string that I have to include in the web.config .

 server name -- abcs.efgh.ed-1.eee.sss.com,1433 (it also contains a port as well) username -- a password -- a db name -- mydb 

I know how to connect to a local database, and I use linkstring.com to link to the link, but connecting to the remote database is a problem for me. help me please

UPDATE

 <connectionStrings> <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="abcs.efgh.ed-1.eee.sss.com,1433;Integrated Security=True;User ID=a;Password=a" /> </connectionStrings> 

An exception I get:

Login failed. Login from an untrusted domain and cannot be used with Windows authentication.

Actually, this is not the Windows authentication I want to use. This is the SQL Server authentication I want.

+4
source share
2 answers

You encounter an error because β€œintegrated security = true” is used for the connection. Use this website to create a connection string. http://www.developerfusion.com/tools/sql-connection-string/

I used the website to create this connection string using your inputs:

 Data Source=abcs.efgh.ed-1.eee.sss.com,1433;Initial Catalog=mydb;Integrated Security=False;User ID=a;Password=a 
+10
source

Set Integrated security =false. to the connection string

If the connection is false, the user ID and password. when true, the current Windows account credentials are used for authentication. The recognized values ​​are true, false, yes, no, and sspi (highly recommended), which is equivalent to true. If the user ID and Password are specified, and the Integrated Security parameter is set to true, the user ID and password will be ignored, and Integrated Security will be used. SqlCredential is a more secure way to provide credentials for a connection that uses SQL Server authentication (Integrated Security = False).

Details in Here

+1
source

Source: https://habr.com/ru/post/1482301/


All Articles