Thursday 22 March 2012

connect to ms sql from C# code

Hi all,

I am trying to connect to a ms sql database from C# code. The code is being executed on the machine where the ms sql server is installed.

Am getting this error:

System.Data.SqlClient.SqlException: 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.) at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParserStateObject.ReadSni Error(TdsParserStateObject stateObj, UInt32 error) at System.Data.SqlClient.TdsParserStateObject.ReadSni (DbAsyncResult asyncResult, TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParserStateObject.ReadPac ket(Int32 bytesExpected) at System.Data.SqlClient.TdsParserStateObject.Re...

The connection string is as followed:

connString = "initial catalog=rolesdb;data source=LOCALHOST\\OFFICESERVERS;Integrated Security=sspi";

SqlConnection conn = new SqlConnection(connString);

conn.Open();

Any idea how to fix this error.

Regards,
bernadetIt seems that user/password information is missing from the connection string?|||

Quote:

Originally Posted by bernadet

Hi all,

I am trying to connect to a ms sql database from C# code. The code is being executed on the machine where the ms sql server is installed.

Am getting this error:

System.Data.SqlClient.SqlException: 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.) at System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParserStateObject.ReadSni Error(TdsParserStateObject stateObj, UInt32 error) at System.Data.SqlClient.TdsParserStateObject.ReadSni (DbAsyncResult asyncResult, TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParserStateObject.ReadPac ket(Int32 bytesExpected) at System.Data.SqlClient.TdsParserStateObject.Re...

The connection string is as followed:

connString = "initial catalog=rolesdb;data source=LOCALHOST\\OFFICESERVERS;Integrated Security=sspi";

SqlConnection conn = new SqlConnection(connString);

conn.Open();

Any idea how to fix this error.

Regards,
bernadet


MySQL provides a managed DLL to aid in connecting to a MySQL database using .NET.

No comments:

Post a Comment