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

G

Guest

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.
 
M

Michael Nemtsev

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 Nietzsch
 
G

Guest

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.
 
W

Willy Denoyette [MVP]

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
 
M

Michael Nemtsev

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
 
G

Guest

Sorry for not specifying...

The version installed is SQL Server 2000 Enterprise Edition.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top