SQL Connection String Formats

Below are a few samples of connection strings for SQL using Windows & SQL mode of Authentication.

Say my server name is ServerXYZ and Database is DBTest

SQL Authentication

Assuming that my SQL login is mku1gis

Server=ServerXYZ;Database=DBTest;Integrated Security=False;User
ID=mku1gis;Password=******;

Data Source=ServerXYZ;Initial Catalog=DBTest;Integrated Security=False;User
ID=mku1gis;Password=******;

Data Source=ServerXYZ;Initial Catalog=DBTest;Integrated Security=False;User
ID=mku1gis;Password=*******;

Windows Authentication

Server=ServerXYZ;Database=DBTest;Integrated Security=SSPI;

Data Source=ServerXYZ;Initial Catalog=DBTest;Integrated Security=SSPI;

Server=ServerXYZ;Database=DBTest;Integrated Security=true;

Few Pointers

  1. Replace server name by server ip and it’ll still work.
  2. Integrated Security = SSPI or Yes or True means Windows Authentication… No credentials required in connection string
  3. Integrated Security = False or No means SQL Authentication… Credentials required in connection string
  4. Data Source <=> Server
  5. Database <=> Initial Catalog
  6. For Windows Authentication, User Id = domain name\user name
  7. For SQL Authentication, User Id = SQL Login name. This name can be checked in the under Databases -> Security -> Login option. Password can be changed anytime in case you don’t remember what you had set earlier by logging to SQL using an admin.SQLConn
Advertisements

6 thoughts on “SQL Connection String Formats

    • Hi Manisha Kumari,

      Thanks for sharing this information across, Here i have an challenge like i have created workflow constant for SQL user authentication and passed the password in secure store string. while entering the same in the connection string (using workflow constant) i’m getting login failed error message.

      Note: User want the password should be encrypt and not to be plain text.. so here i’m passing the password as encrypted. at the same time if i pass the sql password as plain text, then i can able to establish the connection to the sql server.

      • Hey Arun,

        This is some problem to which I haven’t found a solution yet.
        Although the work around could be to use the connection string with original password and restrict permissions for limited users.

  1. Manisha, Thanks for your swift reply..

    We tried the same which you have suggested, but while creating connection string we need to provide plain text again which is not applicable for the security team..

    So please suggest if any other approach for the same.

    Thanks in advance!

    • Arun,

      When we talk about encryption, it is a bigger picture. You send in the key and there is an algorithm for encrypting the data. Same goes for decryption. So, it is not something that can be achieved without having the proper infrastructure (the servers, algorithms for encryption and decryption, etc).

      However, from your situation, what I understand is you want to keep the password hidden from the users.
      For this, you can keep your connection string in the web.config and you can fetch that using some web service. Although in this case also, the connection string in the web.config will have the password in plain text, but unavailable in the workflow.

      • Hi Manisha,

        There is no option to fetch info from web.config using call web service.. So please suggest if there is any other workaround for the same.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s