469,267 Members | 954 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,267 developers. It's quick & easy.

Connecting to SQL Server from ASP.NET page using SqlClient namespa

I need to ask this question again because I am simply not getting it...

Can somebody please tell us what we need to do and explain the solution?
Please see the problem below.

Situation:
Using XP Pro development machine (VS 2003) trying to connect to a W2k3
server running SQL Server 2000 with ASP.NET (C#) using SqlClient.

SqlConnection objConn = new SqlConnection("Trusted_Connection=no;User
ID=sa;Password=MySaPassword;Initial Catalog=MyDatabaseData
Source=MyRemoteServer");
objConn.Open(); //.Open() generates an error.

Error: "SQL Server does not exist or access denied."

We are positive the connection string (creds, server, and database) are
correct because they work from a windows form application written in C#
(using exact same connection code). The firewall is not installed on the
server. Port 2433 is listening. We do know a work-around using
impersonation, but we are looking for an explanation. The W2k3 server is a
member of a domain (if that matters). The connection works when accessing a
W2k server just fine (of course changing only the server name in the
connection string).

One interesting thing is that the Event Viewer on the w2k3 server shows
failed login attempts for ASPNET. But, we are not accessing the database
using windows credentials, we are passing the credentials for SA. So, why is
ASPNET on my box trying to authenticate to the server? Shouldn't only the
credentials for SA be compared against SQL Servers internal security
mechanisms and leave the whole Windows security/authentication out of the
loop entirely.
Dec 21 '05 #1
5 1724
Hello Nate,

Hope this helps: http://support.microsoft.com/default.aspx?kbid=316989
N> Can somebody please tell us what we need to do and explain the
N> solution? Please see the problem below.
N> Situation:
N> Using XP Pro development machine (VS 2003) trying to connect to a
N> W2k3
N> server running SQL Server 2000 with ASP.NET (C#) using SqlClient.
N> SqlConnection objConn = new SqlConnection("Trusted_Connection=no;User
N> ID=sa;Password=MySaPassword;Initial Catalog=MyDatabaseData
N> Source=MyRemoteServer");
N> objConn.Open(); //.Open() generates an error.
N> Error: "SQL Server does not exist or access denied."

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/members/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Dec 21 '05 #2
Thanks Michael, but that error relates to trusted connections. We are using
SQL Authentication and not Windows Authentication to connect.

After more research, we found that for some reason SQL Server was listening
on 2433 and not 1433. We did not configure it this way, and everytime we
change the port back to 1433 and restart SQL server it goes right back to
2433. The only information about this yields that it is caused by either
having VS.NET installed on the same box as SQL server, or the Slammer worm
patch.

So, if we change our connection string to:
Trusted_Connection=no;User ID=sa;Password=MySaPassword;Initial
Catalog=MyDatabaseData;
Source=MyRemoteServer,2433

(notice the ,2433 at the end of the server name)

This is a viable workaround, but we don't like workarounds. We would
prefer that the software function as it was designed to. So, the question
now is, how come SQL server is not letting us change the port that it listens
on? Is it because of VS.NET or the Slammer worm patch?

Thank you in advance.

"Michael Nemtsev" wrote:
Hello Nate,

Hope this helps: http://support.microsoft.com/default.aspx?kbid=316989
N> Can somebody please tell us what we need to do and explain the
N> solution? Please see the problem below.
N> Situation:
N> Using XP Pro development machine (VS 2003) trying to connect to a
N> W2k3
N> server running SQL Server 2000 with ASP.NET (C#) using SqlClient.
N> SqlConnection objConn = new SqlConnection("Trusted_Connection=no;User
N> ID=sa;Password=MySaPassword;Initial Catalog=MyDatabaseData
N> Source=MyRemoteServer");
N> objConn.Open(); //.Open() generates an error.
N> Error: "SQL Server does not exist or access denied."

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/members/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche

Dec 21 '05 #3
I guess you are running "SQL Express" which has the "Hide server option" set
by default. This has the effect of having SQL server to listen on port 2344,
whenever you change the listener port, it will set back to 2433 when SQL
server restarts. I'm not quite sure you can disable this "feature" for SQL
Express, IMO SQL Express was not supposed to be running on the same box as
it's clients.

Willy.
l

"Nate" <Na**@discussions.microsoft.com> wrote in message
news:01**********************************@microsof t.com...
Thanks Michael, but that error relates to trusted connections. We are
using
SQL Authentication and not Windows Authentication to connect.

After more research, we found that for some reason SQL Server was
listening
on 2433 and not 1433. We did not configure it this way, and everytime we
change the port back to 1433 and restart SQL server it goes right back to
2433. The only information about this yields that it is caused by either
having VS.NET installed on the same box as SQL server, or the Slammer worm
patch.

So, if we change our connection string to:
Trusted_Connection=no;User ID=sa;Password=MySaPassword;Initial
Catalog=MyDatabaseData;
Source=MyRemoteServer,2433

(notice the ,2433 at the end of the server name)

This is a viable workaround, but we don't like workarounds. We would
prefer that the software function as it was designed to. So, the question
now is, how come SQL server is not letting us change the port that it
listens
on? Is it because of VS.NET or the Slammer worm patch?

Thank you in advance.

"Michael Nemtsev" wrote:
Hello Nate,

Hope this helps: http://support.microsoft.com/default.aspx?kbid=316989
N> Can somebody please tell us what we need to do and explain the
N> solution? Please see the problem below.
N> Situation:
N> Using XP Pro development machine (VS 2003) trying to connect to a
N> W2k3
N> server running SQL Server 2000 with ASP.NET (C#) using SqlClient.
N> SqlConnection objConn = new SqlConnection("Trusted_Connection=no;User
N> ID=sa;Password=MySaPassword;Initial Catalog=MyDatabaseData
N> Source=MyRemoteServer");
N> objConn.Open(); //.Open() generates an error.
N> Error: "SQL Server does not exist or access denied."

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/members/laflour

"At times one remains faithful to a cause only because its opponents do
not
cease to be insipid." (c) Friedrich Nietzsche

Dec 22 '05 #4
Hello Willy Denoyette [MVP],

There is the answer of how to change SQLExpress port http://mattwoodward.com/blog/index.cfm?commentID=211

W> I guess you are running "SQL Express" which has the "Hide server
W> option" set by default. This has the effect of having SQL server to
W> listen on port 2344, whenever you change the listener port, it will
W> set back to 2433 when SQL server restarts. I'm not quite sure you can
W> disable this "feature" for SQL Express, IMO SQL Express was not
W> supposed to be running on the same box as it's clients.
W>
W> Willy.
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/members/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Dec 22 '05 #5
Sorry for not specifying...

The version installed is SQL Server 2000 Enterprise Edition.

"Willy Denoyette [MVP]" wrote:
I guess you are running "SQL Express" which has the "Hide server option" set
by default. This has the effect of having SQL server to listen on port 2344,
whenever you change the listener port, it will set back to 2433 when SQL
server restarts. I'm not quite sure you can disable this "feature" for SQL
Express, IMO SQL Express was not supposed to be running on the same box as
it's clients.

Willy.
l

"Nate" <Na**@discussions.microsoft.com> wrote in message
news:01**********************************@microsof t.com...
Thanks Michael, but that error relates to trusted connections. We are
using
SQL Authentication and not Windows Authentication to connect.

After more research, we found that for some reason SQL Server was
listening
on 2433 and not 1433. We did not configure it this way, and everytime we
change the port back to 1433 and restart SQL server it goes right back to
2433. The only information about this yields that it is caused by either
having VS.NET installed on the same box as SQL server, or the Slammer worm
patch.

So, if we change our connection string to:
Trusted_Connection=no;User ID=sa;Password=MySaPassword;Initial
Catalog=MyDatabaseData;
Source=MyRemoteServer,2433

(notice the ,2433 at the end of the server name)

This is a viable workaround, but we don't like workarounds. We would
prefer that the software function as it was designed to. So, the question
now is, how come SQL server is not letting us change the port that it
listens
on? Is it because of VS.NET or the Slammer worm patch?

Thank you in advance.

"Michael Nemtsev" wrote:
Hello Nate,

Hope this helps: http://support.microsoft.com/default.aspx?kbid=316989
N> Can somebody please tell us what we need to do and explain the
N> solution? Please see the problem below.
N> Situation:
N> Using XP Pro development machine (VS 2003) trying to connect to a
N> W2k3
N> server running SQL Server 2000 with ASP.NET (C#) using SqlClient.
N> SqlConnection objConn = new SqlConnection("Trusted_Connection=no;User
N> ID=sa;Password=MySaPassword;Initial Catalog=MyDatabaseData
N> Source=MyRemoteServer");
N> objConn.Open(); //.Open() generates an error.
N> Error: "SQL Server does not exist or access denied."

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/members/laflour

"At times one remains faithful to a cause only because its opponents do
not
cease to be insipid." (c) Friedrich Nietzsche


Dec 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Irishmaninusa | last post: by
4 posts views Thread by CodeImp | last post: by
1 post views Thread by Mohammad-Reza | last post: by
1 post views Thread by Jim Bayers | last post: by
10 posts views Thread by Mike Collins | last post: by
3 posts views Thread by Ann Marinas | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.