SQL server management studio - How to connect to SQL server using connection string?

24,753

Because you are using Username and a Password to connect to a database, you should change your connection string to look something like this:

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=False;
User ID=myDomain\myUsername;Password=myPassword;

If you are wondering why:

Integrated Security 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. If User ID and Password are specified and Integrated Security is set to true, the User ID and Password will be ignored and Integrated Security will be used.

P.S

If this is not helping then you may check this also:

Make sure your database engine is configured to accept remote connections:

Start > All Programs > SQL Server 2005 > Configuration

Tools > SQL Server Surface Area Configuration Click on Surface Area

Configuration for Services and Connections Select the instance that is

having a problem > Database Engine > Remote Connections Enable local and remote connections Restart instance

You may need to create an exception on the firewall for the SQL Server instance and port you are using:

Start > Run > Firewall.cpl Click on exceptions tab Add sqlservr.exe

(typically located in C:\Program Files (x86)\Microsoft SQL

Server\MSSQL.x\MSSQL\Bin, check your installs for the actual folder

path) and port (default is 1433) Check your connection string as well

Share:
24,753
HungDQ
Author by

HungDQ

magento developer

Updated on August 09, 2022

Comments

  • HungDQ
    HungDQ almost 2 years

    I cannot connect to SQL Server by using SQL Server Management Studio. I have a connection string:

     <add name="AccountConnStr" connectionString="Data Source=MyIP;Initial Catalog=nvm;Persist Security Info=True;User ID=myID;Password=myPassWord" providerName="System.Data.SqlClient" />
    

    I have tried to connect by entering myIP to Servername, MyID to Login and myPassword to password but still unable to connect. This is the result:

    enter image description here

    Does anyone has ideas ?

    Thank you very much.

  • HungDQ
    HungDQ almost 7 years
    That connection string is using in code and it's working fine. What I'm trying is connect to the database via SQL Server Management Studio.
  • Maa421s
    Maa421s over 6 years
    You can use the connection string in SSMS, but it transmits the credentials in plain text, so IMHO it's not appropriate for a production server
  • variable
    variable over 2 years
    Does the credentials go from client to sql sqlserver as plain text? If so is there any way to secure it?
  • Roxy'Pro
    Roxy'Pro over 2 years
    @variable Usually you are accessing database from a backend ( server, or whatever app is using it.). You could encrypt conn string as a simple string and before using it in your app you could decrypt it, if you are afraid of keeping conn string as a plain text.
  • variable
    variable over 2 years
    No, I meant to ask, whether the connection from the application backend to the database happens in plain text?