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

Connecting to SQL Server on WIN2003 Box

P: n/a
I am trying to connect to a 2003 Server from an ASP.Net page and am getting
the following error message. Can someone please help get me started on how to
track and fix this error? The code I am using is below the error I am
getting.

Error: System.Data.SqlClient.SqlException: SQL Server does not exist or
access denied. at System.Data.SqlClient.ConnectionPool.GetConnection (Boolean&
isInTransaction) at
System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString
options, Boolean& isInTransaction) at
System.Data.SqlClient.SqlConnection.Open() at
testbed.Navigation.Page_Load(Object sender, EventArgs e) in c:\documents and
settings\collinss\vswebcache\605webdev-2_443\testbed\navigation.aspx.cs:line
31

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
SqlDataReader dataReader = null;

try
{
SqlConnection connection = new
SqlConnection("Server=TestWebServer;Database=Commo n;user id=myUserID;
password=myPassword");
SqlCommand command = new SqlCommand("GetNavigationMenu", connection);
command.CommandType = CommandType.StoredProcedure;
connection.Open();
dataReader = command.ExecuteReader();

while (dataReader.Read())
{
string headerMenu = (string)dataReader["HeaderMenu"];
string sectionID = (string)dataReader["SectionID"];
string navigationMenuID = (string)dataReader["NavigationMenuID"];
string menuName = (string)dataReader["MenuName"];
string pageUrl = (string)dataReader["PageUrl"];
string ImageUrl = (string)dataReader["ImageUrl"];
}

dataReader.Close();
connection.Close();
}

catch (System.Exception exception)
{
Response.Write("Error: " + exception.ToString());
return;
}

finally
{
if (dataReader != null)
{
dataReader.Close();
}
}
}
Dec 20 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Verify that you can connect using the specified username and password in SQL
Query Analyzer.

I assume the server is setup with both SQL and Integrated login enabled and
that you have created the specified login in the SQL server and granted the
login access to the given database?

Also, to make sure you can connect, try from a command prompt on the
webserver to telnet to port 1433 (if TCP/IP is the transport you're using).
Regards,

Arild

"Mike Collins" <Mi*********@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
I am trying to connect to a 2003 Server from an ASP.Net page and am getting
the following error message. Can someone please help get me started on how
to
track and fix this error? The code I am using is below the error I am
getting.

Error: System.Data.SqlClient.SqlException: SQL Server does not exist or
access denied. at
System.Data.SqlClient.ConnectionPool.GetConnection (Boolean&
isInTransaction) at
System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString
options, Boolean& isInTransaction) at
System.Data.SqlClient.SqlConnection.Open() at
testbed.Navigation.Page_Load(Object sender, EventArgs e) in c:\documents
and
settings\collinss\vswebcache\605webdev-2_443\testbed\navigation.aspx.cs:line
31

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
SqlDataReader dataReader = null;

try
{
SqlConnection connection = new
SqlConnection("Server=TestWebServer;Database=Commo n;user id=myUserID;
password=myPassword");
SqlCommand command = new SqlCommand("GetNavigationMenu", connection);
command.CommandType = CommandType.StoredProcedure;
connection.Open();
dataReader = command.ExecuteReader();

while (dataReader.Read())
{
string headerMenu = (string)dataReader["HeaderMenu"];
string sectionID = (string)dataReader["SectionID"];
string navigationMenuID = (string)dataReader["NavigationMenuID"];
string menuName = (string)dataReader["MenuName"];
string pageUrl = (string)dataReader["PageUrl"];
string ImageUrl = (string)dataReader["ImageUrl"];
}

dataReader.Close();
connection.Close();
}

catch (System.Exception exception)
{
Response.Write("Error: " + exception.ToString());
return;
}

finally
{
if (dataReader != null)
{
dataReader.Close();
}
}
}

Dec 20 '05 #2

P: n/a
The server is set for both SQL and integrated login. I'm not sure how to use
a command prompt to telnet to port 1433. If you can help with that, I'll give
it a try.

Here is other information that I forgot earlier.
1. I am trying to connect from a Windows XP Professional computer.
2. Currently the server is both a web and database server using Win 2003.
3. We are trying to develop on our XP boxes and test items before moving the
pages over to the test server.

Thanks

"Arild Bakken" wrote:
Verify that you can connect using the specified username and password in SQL
Query Analyzer.

I assume the server is setup with both SQL and Integrated login enabled and
that you have created the specified login in the SQL server and granted the
login access to the given database?

Also, to make sure you can connect, try from a command prompt on the
webserver to telnet to port 1433 (if TCP/IP is the transport you're using).
Regards,

Arild

"Mike Collins" <Mi*********@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
I am trying to connect to a 2003 Server from an ASP.Net page and am getting
the following error message. Can someone please help get me started on how
to
track and fix this error? The code I am using is below the error I am
getting.

Error: System.Data.SqlClient.SqlException: SQL Server does not exist or
access denied. at
System.Data.SqlClient.ConnectionPool.GetConnection (Boolean&
isInTransaction) at
System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString
options, Boolean& isInTransaction) at
System.Data.SqlClient.SqlConnection.Open() at
testbed.Navigation.Page_Load(Object sender, EventArgs e) in c:\documents
and
settings\collinss\vswebcache\605webdev-2_443\testbed\navigation.aspx.cs:line
31

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
SqlDataReader dataReader = null;

try
{
SqlConnection connection = new
SqlConnection("Server=TestWebServer;Database=Commo n;user id=myUserID;
password=myPassword");
SqlCommand command = new SqlCommand("GetNavigationMenu", connection);
command.CommandType = CommandType.StoredProcedure;
connection.Open();
dataReader = command.ExecuteReader();

while (dataReader.Read())
{
string headerMenu = (string)dataReader["HeaderMenu"];
string sectionID = (string)dataReader["SectionID"];
string navigationMenuID = (string)dataReader["NavigationMenuID"];
string menuName = (string)dataReader["MenuName"];
string pageUrl = (string)dataReader["PageUrl"];
string ImageUrl = (string)dataReader["ImageUrl"];
}

dataReader.Close();
connection.Close();
}

catch (System.Exception exception)
{
Response.Write("Error: " + exception.ToString());
return;
}

finally
{
if (dataReader != null)
{
dataReader.Close();
}
}
}


Dec 20 '05 #3

P: n/a
Mike,

The issue arises from the fact that you are running with default
credentials in ASP.NET. By default, all code that runs in ASP.NET runs
under the ASPNET local user. This doesn't have access to network resources.

In order to get around this, you have to impersonate a user (through
code, or through a declaration in web.config) which has rights to the
network, and to SQL Server.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mike Collins" <Mi*********@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
The server is set for both SQL and integrated login. I'm not sure how to
use
a command prompt to telnet to port 1433. If you can help with that, I'll
give
it a try.

Here is other information that I forgot earlier.
1. I am trying to connect from a Windows XP Professional computer.
2. Currently the server is both a web and database server using Win 2003.
3. We are trying to develop on our XP boxes and test items before moving
the
pages over to the test server.

Thanks

"Arild Bakken" wrote:
Verify that you can connect using the specified username and password in
SQL
Query Analyzer.

I assume the server is setup with both SQL and Integrated login enabled
and
that you have created the specified login in the SQL server and granted
the
login access to the given database?

Also, to make sure you can connect, try from a command prompt on the
webserver to telnet to port 1433 (if TCP/IP is the transport you're
using).
Regards,

Arild

"Mike Collins" <Mi*********@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
>I am trying to connect to a 2003 Server from an ASP.Net page and am
>getting
> the following error message. Can someone please help get me started on
> how
> to
> track and fix this error? The code I am using is below the error I am
> getting.
>
> Error: System.Data.SqlClient.SqlException: SQL Server does not exist or
> access denied. at
> System.Data.SqlClient.ConnectionPool.GetConnection (Boolean&
> isInTransaction) at
> System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString
> options, Boolean& isInTransaction) at
> System.Data.SqlClient.SqlConnection.Open() at
> testbed.Navigation.Page_Load(Object sender, EventArgs e) in
> c:\documents
> and
> settings\collinss\vswebcache\605webdev-2_443\testbed\navigation.aspx.cs:line
> 31
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> SqlDataReader dataReader = null;
>
> try
> {
> SqlConnection connection = new
> SqlConnection("Server=TestWebServer;Database=Commo n;user id=myUserID;
> password=myPassword");
> SqlCommand command = new SqlCommand("GetNavigationMenu", connection);
> command.CommandType = CommandType.StoredProcedure;
> connection.Open();
> dataReader = command.ExecuteReader();
>
> while (dataReader.Read())
> {
> string headerMenu = (string)dataReader["HeaderMenu"];
> string sectionID = (string)dataReader["SectionID"];
> string navigationMenuID = (string)dataReader["NavigationMenuID"];
> string menuName = (string)dataReader["MenuName"];
> string pageUrl = (string)dataReader["PageUrl"];
> string ImageUrl = (string)dataReader["ImageUrl"];
> }
>
> dataReader.Close();
> connection.Close();
> }
>
> catch (System.Exception exception)
> {
> Response.Write("Error: " + exception.ToString());
> return;
> }
>
> finally
> {
> if (dataReader != null)
> {
> dataReader.Close();
> }
> }
> }


Dec 20 '05 #4

P: n/a
To try connecting to the server using telnet:

1. Start a command prompt (Start / Run / type "cmd" and press enter).
2. Type: telnet TestWebServer 1433

This only works if the server is configured to use TCP/IP and only if the
SQL server instance is using port 1433 - you can check that on the server
using the SQL server configuration tool.

Another thing, is the SQL instance the default instance or is it a named
instance? If it is a named instance you need to include the instance name in
the server name, like servername\instancename.
Arild

"Mike Collins" <Mi*********@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
The server is set for both SQL and integrated login. I'm not sure how to
use
a command prompt to telnet to port 1433. If you can help with that, I'll
give
it a try.

Here is other information that I forgot earlier.
1. I am trying to connect from a Windows XP Professional computer.
2. Currently the server is both a web and database server using Win 2003.
3. We are trying to develop on our XP boxes and test items before moving
the
pages over to the test server.

Thanks

"Arild Bakken" wrote:
Verify that you can connect using the specified username and password in
SQL
Query Analyzer.

I assume the server is setup with both SQL and Integrated login enabled
and
that you have created the specified login in the SQL server and granted
the
login access to the given database?

Also, to make sure you can connect, try from a command prompt on the
webserver to telnet to port 1433 (if TCP/IP is the transport you're
using).
Regards,

Arild

"Mike Collins" <Mi*********@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
>I am trying to connect to a 2003 Server from an ASP.Net page and am
>getting
> the following error message. Can someone please help get me started on
> how
> to
> track and fix this error? The code I am using is below the error I am
> getting.
>
> Error: System.Data.SqlClient.SqlException: SQL Server does not exist or
> access denied. at
> System.Data.SqlClient.ConnectionPool.GetConnection (Boolean&
> isInTransaction) at
> System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString
> options, Boolean& isInTransaction) at
> System.Data.SqlClient.SqlConnection.Open() at
> testbed.Navigation.Page_Load(Object sender, EventArgs e) in
> c:\documents
> and
> settings\collinss\vswebcache\605webdev-2_443\testbed\navigation.aspx.cs:line
> 31
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> SqlDataReader dataReader = null;
>
> try
> {
> SqlConnection connection = new
> SqlConnection("Server=TestWebServer;Database=Commo n;user id=myUserID;
> password=myPassword");
> SqlCommand command = new SqlCommand("GetNavigationMenu", connection);
> command.CommandType = CommandType.StoredProcedure;
> connection.Open();
> dataReader = command.ExecuteReader();
>
> while (dataReader.Read())
> {
> string headerMenu = (string)dataReader["HeaderMenu"];
> string sectionID = (string)dataReader["SectionID"];
> string navigationMenuID = (string)dataReader["NavigationMenuID"];
> string menuName = (string)dataReader["MenuName"];
> string pageUrl = (string)dataReader["PageUrl"];
> string ImageUrl = (string)dataReader["ImageUrl"];
> }
>
> dataReader.Close();
> connection.Close();
> }
>
> catch (System.Exception exception)
> {
> Response.Write("Error: " + exception.ToString());
> return;
> }
>
> finally
> {
> if (dataReader != null)
> {
> dataReader.Close();
> }
> }
> }


Dec 20 '05 #5

P: n/a
On W2K3 aspnet runs as NETWORK_SERVICE, not as aspnet.

Willy.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uK**************@TK2MSFTNGP10.phx.gbl...
Mike,

The issue arises from the fact that you are running with default
credentials in ASP.NET. By default, all code that runs in ASP.NET runs
under the ASPNET local user. This doesn't have access to network
resources.

In order to get around this, you have to impersonate a user (through
code, or through a declaration in web.config) which has rights to the
network, and to SQL Server.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mike Collins" <Mi*********@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
The server is set for both SQL and integrated login. I'm not sure how to
use
a command prompt to telnet to port 1433. If you can help with that, I'll
give
it a try.

Here is other information that I forgot earlier.
1. I am trying to connect from a Windows XP Professional computer.
2. Currently the server is both a web and database server using Win 2003.
3. We are trying to develop on our XP boxes and test items before moving
the
pages over to the test server.

Thanks

"Arild Bakken" wrote:
Verify that you can connect using the specified username and password in
SQL
Query Analyzer.

I assume the server is setup with both SQL and Integrated login enabled
and
that you have created the specified login in the SQL server and granted
the
login access to the given database?

Also, to make sure you can connect, try from a command prompt on the
webserver to telnet to port 1433 (if TCP/IP is the transport you're
using).
Regards,

Arild

"Mike Collins" <Mi*********@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
>I am trying to connect to a 2003 Server from an ASP.Net page and am
>getting
> the following error message. Can someone please help get me started on
> how
> to
> track and fix this error? The code I am using is below the error I am
> getting.
>
> Error: System.Data.SqlClient.SqlException: SQL Server does not exist
> or
> access denied. at
> System.Data.SqlClient.ConnectionPool.GetConnection (Boolean&
> isInTransaction) at
> System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString
> options, Boolean& isInTransaction) at
> System.Data.SqlClient.SqlConnection.Open() at
> testbed.Navigation.Page_Load(Object sender, EventArgs e) in
> c:\documents
> and
> settings\collinss\vswebcache\605webdev-2_443\testbed\navigation.aspx.cs:line
> 31
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> SqlDataReader dataReader = null;
>
> try
> {
> SqlConnection connection = new
> SqlConnection("Server=TestWebServer;Database=Commo n;user id=myUserID;
> password=myPassword");
> SqlCommand command = new SqlCommand("GetNavigationMenu", connection);
> command.CommandType = CommandType.StoredProcedure;
> connection.Open();
> dataReader = command.ExecuteReader();
>
> while (dataReader.Read())
> {
> string headerMenu = (string)dataReader["HeaderMenu"];
> string sectionID = (string)dataReader["SectionID"];
> string navigationMenuID = (string)dataReader["NavigationMenuID"];
> string menuName = (string)dataReader["MenuName"];
> string pageUrl = (string)dataReader["PageUrl"];
> string ImageUrl = (string)dataReader["ImageUrl"];
> }
>
> dataReader.Close();
> connection.Close();
> }
>
> catch (System.Exception exception)
> {
> Response.Write("Error: " + exception.ToString());
> return;
> }
>
> finally
> {
> if (dataReader != null)
> {
> dataReader.Close();
> }
> }
> }


Dec 20 '05 #6

P: n/a
Set your connection string to use integrated security, and add NETWORK
SERVICE as a user and grant appropriate rights.
NT AUTHORITY\NETWORK USER is the the default user running aspnet.
Note that I noticed that you are running IIS and SQL on the same box (W2K3),
above is only applicable in such configuration.

Willy.

"Mike Collins" <Mi*********@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
I am trying to connect to a 2003 Server from an ASP.Net page and am getting
the following error message. Can someone please help get me started on how
to
track and fix this error? The code I am using is below the error I am
getting.

Error: System.Data.SqlClient.SqlException: SQL Server does not exist or
access denied. at
System.Data.SqlClient.ConnectionPool.GetConnection (Boolean&
isInTransaction) at
System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString
options, Boolean& isInTransaction) at
System.Data.SqlClient.SqlConnection.Open() at
testbed.Navigation.Page_Load(Object sender, EventArgs e) in c:\documents
and
settings\collinss\vswebcache\605webdev-2_443\testbed\navigation.aspx.cs:line
31

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
SqlDataReader dataReader = null;

try
{
SqlConnection connection = new
SqlConnection("Server=TestWebServer;Database=Commo n;user id=myUserID;
password=myPassword");
SqlCommand command = new SqlCommand("GetNavigationMenu", connection);
command.CommandType = CommandType.StoredProcedure;
connection.Open();
dataReader = command.ExecuteReader();

while (dataReader.Read())
{
string headerMenu = (string)dataReader["HeaderMenu"];
string sectionID = (string)dataReader["SectionID"];
string navigationMenuID = (string)dataReader["NavigationMenuID"];
string menuName = (string)dataReader["MenuName"];
string pageUrl = (string)dataReader["PageUrl"];
string ImageUrl = (string)dataReader["ImageUrl"];
}

dataReader.Close();
connection.Close();
}

catch (System.Exception exception)
{
Response.Write("Error: " + exception.ToString());
return;
}

finally
{
if (dataReader != null)
{
dataReader.Close();
}
}
}

Dec 20 '05 #7

P: n/a
Thanks to all of you for your input. I'm going to look into adding rights in
webconfig. I'll make another post, in a couple of days, if I need further
assistance. Thanks again.

"Arild Bakken" wrote:
To try connecting to the server using telnet:

1. Start a command prompt (Start / Run / type "cmd" and press enter).
2. Type: telnet TestWebServer 1433

This only works if the server is configured to use TCP/IP and only if the
SQL server instance is using port 1433 - you can check that on the server
using the SQL server configuration tool.

Another thing, is the SQL instance the default instance or is it a named
instance? If it is a named instance you need to include the instance name in
the server name, like servername\instancename.
Arild

"Mike Collins" <Mi*********@discussions.microsoft.com> wrote in message
news:D0**********************************@microsof t.com...
The server is set for both SQL and integrated login. I'm not sure how to
use
a command prompt to telnet to port 1433. If you can help with that, I'll
give
it a try.

Here is other information that I forgot earlier.
1. I am trying to connect from a Windows XP Professional computer.
2. Currently the server is both a web and database server using Win 2003.
3. We are trying to develop on our XP boxes and test items before moving
the
pages over to the test server.

Thanks

"Arild Bakken" wrote:
Verify that you can connect using the specified username and password in
SQL
Query Analyzer.

I assume the server is setup with both SQL and Integrated login enabled
and
that you have created the specified login in the SQL server and granted
the
login access to the given database?

Also, to make sure you can connect, try from a command prompt on the
webserver to telnet to port 1433 (if TCP/IP is the transport you're
using).
Regards,

Arild

"Mike Collins" <Mi*********@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
>I am trying to connect to a 2003 Server from an ASP.Net page and am
>getting
> the following error message. Can someone please help get me started on
> how
> to
> track and fix this error? The code I am using is below the error I am
> getting.
>
> Error: System.Data.SqlClient.SqlException: SQL Server does not exist or
> access denied. at
> System.Data.SqlClient.ConnectionPool.GetConnection (Boolean&
> isInTransaction) at
> System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString
> options, Boolean& isInTransaction) at
> System.Data.SqlClient.SqlConnection.Open() at
> testbed.Navigation.Page_Load(Object sender, EventArgs e) in
> c:\documents
> and
> settings\collinss\vswebcache\605webdev-2_443\testbed\navigation.aspx.cs:line
> 31
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> SqlDataReader dataReader = null;
>
> try
> {
> SqlConnection connection = new
> SqlConnection("Server=TestWebServer;Database=Commo n;user id=myUserID;
> password=myPassword");
> SqlCommand command = new SqlCommand("GetNavigationMenu", connection);
> command.CommandType = CommandType.StoredProcedure;
> connection.Open();
> dataReader = command.ExecuteReader();
>
> while (dataReader.Read())
> {
> string headerMenu = (string)dataReader["HeaderMenu"];
> string sectionID = (string)dataReader["SectionID"];
> string navigationMenuID = (string)dataReader["NavigationMenuID"];
> string menuName = (string)dataReader["MenuName"];
> string pageUrl = (string)dataReader["PageUrl"];
> string ImageUrl = (string)dataReader["ImageUrl"];
> }
>
> dataReader.Close();
> connection.Close();
> }
>
> catch (System.Exception exception)
> {
> Response.Write("Error: " + exception.ToString());
> return;
> }
>
> finally
> {
> if (dataReader != null)
> {
> dataReader.Close();
> }
> }
> }


Dec 20 '05 #8

P: n/a
I'm confused. If the connection string is specifying "User
Id=sa;Password=sa_password", then why in all of creation is ASP.NET sending
credentials as ASPNET and not "sa"? What's the point in having SQL
credentials if you can't use them?

"Willy Denoyette [MVP]" wrote:
Set your connection string to use integrated security, and add NETWORK
SERVICE as a user and grant appropriate rights.
NT AUTHORITY\NETWORK USER is the the default user running aspnet.
Note that I noticed that you are running IIS and SQL on the same box (W2K3),
above is only applicable in such configuration.

Willy.

"Mike Collins" <Mi*********@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
I am trying to connect to a 2003 Server from an ASP.Net page and am getting
the following error message. Can someone please help get me started on how
to
track and fix this error? The code I am using is below the error I am
getting.

Error: System.Data.SqlClient.SqlException: SQL Server does not exist or
access denied. at
System.Data.SqlClient.ConnectionPool.GetConnection (Boolean&
isInTransaction) at
System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString
options, Boolean& isInTransaction) at
System.Data.SqlClient.SqlConnection.Open() at
testbed.Navigation.Page_Load(Object sender, EventArgs e) in c:\documents
and
settings\collinss\vswebcache\605webdev-2_443\testbed\navigation.aspx.cs:line
31

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
SqlDataReader dataReader = null;

try
{
SqlConnection connection = new
SqlConnection("Server=TestWebServer;Database=Commo n;user id=myUserID;
password=myPassword");
SqlCommand command = new SqlCommand("GetNavigationMenu", connection);
command.CommandType = CommandType.StoredProcedure;
connection.Open();
dataReader = command.ExecuteReader();

while (dataReader.Read())
{
string headerMenu = (string)dataReader["HeaderMenu"];
string sectionID = (string)dataReader["SectionID"];
string navigationMenuID = (string)dataReader["NavigationMenuID"];
string menuName = (string)dataReader["MenuName"];
string pageUrl = (string)dataReader["PageUrl"];
string ImageUrl = (string)dataReader["ImageUrl"];
}

dataReader.Close();
connection.Close();
}

catch (System.Exception exception)
{
Response.Write("Error: " + exception.ToString());
return;
}

finally
{
if (dataReader != null)
{
dataReader.Close();
}
}
}


Dec 20 '05 #9

P: n/a
Did I say that you can't use them?
I only said that in a configuration that runs SQL and IIS (aspnet) on the
same box, you better use integrated security.
Note that from this code

SqlConnection("Server=TestWebServer;Database=Commo n;user id=myUserID;
> password=myPassword");

it's impossible for us to tell whether the specified credentials are correct
or that the Servername is correct, so to eliminate the credentials as a
possible cause, specify integrated security.
Note that, whatever the configuration is, you should always prefer
integrated security over explicit hard coded user credentials, especially
sa credentials.

Willy.
"Nate" <Na**@discussions.microsoft.com> wrote in message
news:54**********************************@microsof t.com... I'm confused. If the connection string is specifying "User
Id=sa;Password=sa_password", then why in all of creation is ASP.NET
sending
credentials as ASPNET and not "sa"? What's the point in having SQL
credentials if you can't use them?

"Willy Denoyette [MVP]" wrote:
Set your connection string to use integrated security, and add NETWORK
SERVICE as a user and grant appropriate rights.
NT AUTHORITY\NETWORK USER is the the default user running aspnet.
Note that I noticed that you are running IIS and SQL on the same box
(W2K3),
above is only applicable in such configuration.

Willy.

"Mike Collins" <Mi*********@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
>I am trying to connect to a 2003 Server from an ASP.Net page and am
>getting
> the following error message. Can someone please help get me started on
> how
> to
> track and fix this error? The code I am using is below the error I am
> getting.
>
> Error: System.Data.SqlClient.SqlException: SQL Server does not exist or
> access denied. at
> System.Data.SqlClient.ConnectionPool.GetConnection (Boolean&
> isInTransaction) at
> System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString
> options, Boolean& isInTransaction) at
> System.Data.SqlClient.SqlConnection.Open() at
> testbed.Navigation.Page_Load(Object sender, EventArgs e) in
> c:\documents
> and
> settings\collinss\vswebcache\605webdev-2_443\testbed\navigation.aspx.cs:line
> 31
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> SqlDataReader dataReader = null;
>
> try
> {
> SqlConnection connection = new
> SqlConnection("Server=TestWebServer;Database=Commo n;user id=myUserID;
> password=myPassword");
> SqlCommand command = new SqlCommand("GetNavigationMenu", connection);
> command.CommandType = CommandType.StoredProcedure;
> connection.Open();
> dataReader = command.ExecuteReader();
>
> while (dataReader.Read())
> {
> string headerMenu = (string)dataReader["HeaderMenu"];
> string sectionID = (string)dataReader["SectionID"];
> string navigationMenuID = (string)dataReader["NavigationMenuID"];
> string menuName = (string)dataReader["MenuName"];
> string pageUrl = (string)dataReader["PageUrl"];
> string ImageUrl = (string)dataReader["ImageUrl"];
> }
>
> dataReader.Close();
> connection.Close();
> }
>
> catch (System.Exception exception)
> {
> Response.Write("Error: " + exception.ToString());
> return;
> }
>
> finally
> {
> if (dataReader != null)
> {
> dataReader.Close();
> }
> }
> }


Dec 20 '05 #10

P: n/a
Check the Windows Firewall (it can be found in the control panel).

--

Derek Davis
dd******@gmail.com

"Mike Collins" <Mi*********@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
I am trying to connect to a 2003 Server from an ASP.Net page and am getting
the following error message. Can someone please help get me started on how
to
track and fix this error? The code I am using is below the error I am
getting.

Error: System.Data.SqlClient.SqlException: SQL Server does not exist or
access denied. at
System.Data.SqlClient.ConnectionPool.GetConnection (Boolean&
isInTransaction) at
System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString
options, Boolean& isInTransaction) at
System.Data.SqlClient.SqlConnection.Open() at
testbed.Navigation.Page_Load(Object sender, EventArgs e) in c:\documents
and
settings\collinss\vswebcache\605webdev-2_443\testbed\navigation.aspx.cs:line
31

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
SqlDataReader dataReader = null;

try
{
SqlConnection connection = new
SqlConnection("Server=TestWebServer;Database=Commo n;user id=myUserID;
password=myPassword");
SqlCommand command = new SqlCommand("GetNavigationMenu", connection);
command.CommandType = CommandType.StoredProcedure;
connection.Open();
dataReader = command.ExecuteReader();

while (dataReader.Read())
{
string headerMenu = (string)dataReader["HeaderMenu"];
string sectionID = (string)dataReader["SectionID"];
string navigationMenuID = (string)dataReader["NavigationMenuID"];
string menuName = (string)dataReader["MenuName"];
string pageUrl = (string)dataReader["PageUrl"];
string ImageUrl = (string)dataReader["ImageUrl"];
}

dataReader.Close();
connection.Close();
}

catch (System.Exception exception)
{
Response.Write("Error: " + exception.ToString());
return;
}

finally
{
if (dataReader != null)
{
dataReader.Close();
}
}
}

Dec 21 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.