By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,701 Members | 2,006 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,701 IT Pros & Developers. It's quick & easy.

Login fails for SQL Server

P: n/a
Greetings,

I am attempting to use the following code to establish a connection to a SQL
Server database. However, when I execute the code, I receive the following
error:

"Login failed for user 'guest'. The user is not associated with a trusted
SQL Server connection."

SqlConnection conn = new SqlConnection("Data
Source=HOME-PC\\SQLEXPRESS;Initial Catalog=Contacts;User ID=guest");
conn.Open();

[Note: I am using Windows Authentication].

Any ideas?

Thanks in advance!
Jun 27 '08 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Sherwood wrote:
I am attempting to use the following code to establish a connection to a SQL
Server database. However, when I execute the code, I receive the following
error:

"Login failed for user 'guest'. The user is not associated with a trusted
SQL Server connection."

SqlConnection conn = new SqlConnection("Data
Source=HOME-PC\\SQLEXPRESS;Initial Catalog=Contacts;User ID=guest");
conn.Open();

[Note: I am using Windows Authentication].

Any ideas?
First of all, the guest account has been disabled by default on Windows
installations since the stone age. It's a remnant of a more innocent time
where vulnerabilties were not systematically exploited.

Second, if you're using Windows authentication you should leave out the User
ID altogether. The connection will use the credentials of the user the
application is running under, which is usually what you want.

Third, this is the #1 error when making SQL connections, and I'm not
convinced you googled very diligently before coming here.

--
J.
http://symbolsprose.blogspot.com
Jun 27 '08 #2

P: n/a
Thanks so much. However, when I remove the User ID I still get the same error:

"Login failed for user ''. The user is not associated with a trusted SQL
Server connection."

By the way, I am using SQL Server 2005 Express Edition if that matters.

"Jeroen Mostert" wrote:
Sherwood wrote:
I am attempting to use the following code to establish a connection to a SQL
Server database. However, when I execute the code, I receive the following
error:

"Login failed for user 'guest'. The user is not associated with a trusted
SQL Server connection."

SqlConnection conn = new SqlConnection("Data
Source=HOME-PC\\SQLEXPRESS;Initial Catalog=Contacts;User ID=guest");
conn.Open();

[Note: I am using Windows Authentication].

Any ideas?
First of all, the guest account has been disabled by default on Windows
installations since the stone age. It's a remnant of a more innocent time
where vulnerabilties were not systematically exploited.

Second, if you're using Windows authentication you should leave out the User
ID altogether. The connection will use the credentials of the user the
application is running under, which is usually what you want.

Third, this is the #1 error when making SQL connections, and I'm not
convinced you googled very diligently before coming here.

--
J.
http://symbolsprose.blogspot.com
Jun 27 '08 #3

P: n/a
Sherwood wrote:
Thanks so much. However, when I remove the User ID I still get the same error:

"Login failed for user ''. The user is not associated with a trusted SQL
Server connection."
Check the event log. It should say exactly what login is failing. You *did*
create a login and a user mapping in the database, did you?

Recheck your connection string. You can use "." or "localhost" for the
server name to force a local login rather than a login over TCP/IP and/or a
domain lookup.
By the way, I am using SQL Server 2005 Express Edition if that matters.
It does not. Express by default installs itself as a named instance, but
that's it.

--
J.
http://symbolsprose.blogspot.com
Jun 27 '08 #4

P: n/a
I did create a login and user mapping. However, I think the problem lies
with SQL Server. When I attempt to log in, I receive the following error:

“Cannot connect to HOME-PC\SQLEXPRESS.
Additional information:
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.) (Microsoft SQL Server,
Error: 233)”

I'll have to troubleshoot this on the SQL Server side and see what I come up
with.

Thanks again.

"Jeroen Mostert" wrote:
Sherwood wrote:
Thanks so much. However, when I remove the User ID I still get the same error:

"Login failed for user ''. The user is not associated with a trusted SQL
Server connection."
Check the event log. It should say exactly what login is failing. You *did*
create a login and a user mapping in the database, did you?

Recheck your connection string. You can use "." or "localhost" for the
server name to force a local login rather than a login over TCP/IP and/or a
domain lookup.
By the way, I am using SQL Server 2005 Express Edition if that matters.
It does not. Express by default installs itself as a named instance, but
that's it.

--
J.
http://symbolsprose.blogspot.com
Jun 27 '08 #5

P: n/a
While installing SQL Server which authentication you choose for your SQL
Server.
Please try to connect to SQL Server using SQL Server Management Studio. Try
logging in using 'sa' username; this is default system administrator account
of sql server.

Try this if you have SQL Server Authentication

SqlConnection conn = new SqlConnection("Data
Source=HOME-PC\\SQLEXPRESS;Initial Catalog=Contacts;UID=sa;
password=yourpassword");

Or try this if you have windows authentication

SqlConnection conn = new SqlConnection("Data
Source=HOME-PC\\SQLEXPRESS;Initial Catalog=Contacts;Integrated
Security=True");

--
Regards,
Mudassar Hassan
http://mudassarhassan.spaces.live.com/
"Sherwood" wrote:
I did create a login and user mapping. However, I think the problem lies
with SQL Server. When I attempt to log in, I receive the following error:

“Cannot connect to HOME-PC\SQLEXPRESS.
Additional information:
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.) (Microsoft SQL Server,
Error: 233)”

I'll have to troubleshoot this on the SQL Server side and see what I come up
with.

Thanks again.

"Jeroen Mostert" wrote:
Sherwood wrote:
Thanks so much. However, when I remove the User ID I still get the same error:
>
"Login failed for user ''. The user is not associated with a trusted SQL
Server connection."
>
Check the event log. It should say exactly what login is failing. You *did*
create a login and a user mapping in the database, did you?

Recheck your connection string. You can use "." or "localhost" for the
server name to force a local login rather than a login over TCP/IP and/or a
domain lookup.
By the way, I am using SQL Server 2005 Express Edition if that matters.
>
It does not. Express by default installs itself as a named instance, but
that's it.

--
J.
http://symbolsprose.blogspot.com
Jun 27 '08 #6

P: n/a
Thanks. That worked!

"Mudassar Hassan" wrote:
While installing SQL Server which authentication you choose for your SQL
Server.
Please try to connect to SQL Server using SQL Server Management Studio. Try
logging in using 'sa' username; this is default system administrator account
of sql server.

Try this if you have SQL Server Authentication

SqlConnection conn = new SqlConnection("Data
Source=HOME-PC\\SQLEXPRESS;Initial Catalog=Contacts;UID=sa;
password=yourpassword");

Or try this if you have windows authentication

SqlConnection conn = new SqlConnection("Data
Source=HOME-PC\\SQLEXPRESS;Initial Catalog=Contacts;Integrated
Security=True");

--
Regards,
Mudassar Hassan
http://mudassarhassan.spaces.live.com/
"Sherwood" wrote:
I did create a login and user mapping. However, I think the problem lies
with SQL Server. When I attempt to log in, I receive the following error:

“Cannot connect to HOME-PC\SQLEXPRESS.
Additional information:
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.) (Microsoft SQL Server,
Error: 233)”

I'll have to troubleshoot this on the SQL Server side and see what I come up
with.

Thanks again.

"Jeroen Mostert" wrote:
Sherwood wrote:
Thanks so much. However, when I remove the User ID I still get the same error:

"Login failed for user ''. The user is not associated with a trusted SQL
Server connection."

Check the event log. It should say exactly what login is failing. You *did*
create a login and a user mapping in the database, did you?
>
Recheck your connection string. You can use "." or "localhost" for the
server name to force a local login rather than a login over TCP/IP and/or a
domain lookup.
>
By the way, I am using SQL Server 2005 Express Edition if that matters.

It does not. Express by default installs itself as a named instance, but
that's it.
>
--
J.
http://symbolsprose.blogspot.com
>
Jun 27 '08 #7

P: n/a
If that works please Choose Question Answered for my post
Thanks
--
Regards,
Mudassar Hassan
http://mudassarhassan.spaces.live.com/
"Sherwood" wrote:
Thanks. That worked!

"Mudassar Hassan" wrote:
While installing SQL Server which authentication you choose for your SQL
Server.
Please try to connect to SQL Server using SQL Server Management Studio. Try
logging in using 'sa' username; this is default system administrator account
of sql server.

Try this if you have SQL Server Authentication

SqlConnection conn = new SqlConnection("Data
Source=HOME-PC\\SQLEXPRESS;Initial Catalog=Contacts;UID=sa;
password=yourpassword");

Or try this if you have windows authentication

SqlConnection conn = new SqlConnection("Data
Source=HOME-PC\\SQLEXPRESS;Initial Catalog=Contacts;Integrated
Security=True");

--
Regards,
Mudassar Hassan
http://mudassarhassan.spaces.live.com/
"Sherwood" wrote:
I did create a login and user mapping. However, I think the problem lies
with SQL Server. When I attempt to log in, I receive the following error:
>
“Cannot connect to HOME-PC\SQLEXPRESS.
Additional information:
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.) (Microsoft SQL Server,
Error: 233)”
>
I'll have to troubleshoot this on the SQL Server side and see what I come up
with.
>
Thanks again.
>
"Jeroen Mostert" wrote:
>
Sherwood wrote:
Thanks so much. However, when I remove the User ID I still get the same error:
>
"Login failed for user ''. The user is not associated with a trusted SQL
Server connection."
>
Check the event log. It should say exactly what login is failing. You *did*
create a login and a user mapping in the database, did you?

Recheck your connection string. You can use "." or "localhost" for the
server name to force a local login rather than a login over TCP/IP and/or a
domain lookup.

By the way, I am using SQL Server 2005 Express Edition if that matters.
>
It does not. Express by default installs itself as a named instance, but
that's it.

--
J.
http://symbolsprose.blogspot.com
Jun 27 '08 #8

P: n/a
On Jun 9, 6:20*pm, Sherwood <Sherw...@discussions.microsoft.com>
wrote:
Greetings,

I am attempting to use the following code to establish a connection to a SQL
Server database. *However, when I execute the code, I receive the following
error:

"Login failed for user 'guest'. The user is not associated with a trusted
SQL Server connection."

SqlConnection conn = new SqlConnection("Data
Source=HOME-PC\\SQLEXPRESS;Initial Catalog=Contacts;User ID=guest");
conn.Open();

[Note: *I am using Windows Authentication].

Any ideas?

Thanks in advance!
Yes,

Change the user, r u using SQL authentication?
Try to use integrated security instead
Jun 27 '08 #9

This discussion thread is closed

Replies have been disabled for this discussion.