Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sql connection string using sql authentication

I am using this sql connection string :

string connection = "data source=OSBORNECHARLES2;initial catalog=TWO;
integrated security=False;User ID=userid;Password=PWD";

I am getting this error :

A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)

If I set integrated security=True; it is working.
If I log in with another window user I'm getting error.

Can you please tell me why I'm getting this error.

like image 969
Neeru Avatar asked Sep 04 '12 13:09

Neeru


People also ask

How do I connect to SQL Server with SQL authentication?

In SQL Server Management Studio Object Explorer, right-click the server, and then click Properties. On the Security page, under Server authentication, select the new server authentication mode, and then click OK.

How do I create a SQL connection string?

Server=ServerName;Database=DatabaseName;User Id=UserName;Password=UserPassword; This usage type may cause vulnerabilities in our application thus using windows authentication can provide more security in our applications. The following connection string will connect the database using windows authentication.

How do I find the SQL connection string?

Right-click on your connection and select "Properties". You will get the Properties window for your connection. Find the "Connection String" property and select the "connection string". So now your connection string is in your hands; you can use it anywhere you want.

What is the SQL provider in a connection string?

Provider=MSOLEDBSQL;Server=myServerName,myPortNumber;Database=myDataBase;UID=myUsername;PWD=myPassword; The default SQL Server port is 1433 and there is no need to specify that in the connection string.


2 Answers

I think you can you use this

Data Source=myServerAddress;Initial Catalog=myDataBase;Integrated Security=SSPI;User ID=myDomain\myUsername;Password=myPassword;
like image 168
Hassanuzzaman Avatar answered Sep 22 '22 13:09

Hassanuzzaman


I am going to venture a guess here. I would assume that your instance of SQL is set to only allow Windows\Integrated logins. The userid\password you are setting in the connection string is for SQL logins only, you can't pass another windows user that way. It would appear that you are attempting to do impersonation using the connection string. I wish it was that simple.

So you likely either need to enable mixed mode security on your sql instance and create sql logins for this user, or you need to impersonate that windows user in your application and then use integrated security.

like image 37
Brian Rudolph Avatar answered Sep 21 '22 13:09

Brian Rudolph