473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Connecting to SQL Server on WIN2003 Box

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
10 1405
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: mike | last post by:
What is the proper method for setting up visual studio 2003 to store and run solutions on a windoes 2003 webserver? Using vstudio enterprise on a WinXP client. Major issue is that SafeSource...
0
by: Randy | last post by:
Hi all, I'm a developer on the database backend and need to figure out how to get a c++ .net executable to run on a win2003 server. The executable transfers data between oracla and sql server...
1
by: lhansen | last post by:
I've seen posts similar to this, but have not found the magic bullet to solve my problem.. I have an asp page (see source code below) running on IIS 6.0 on Win2003 Server that tries to get file...
0
by: CjB | last post by:
Good Morning, I am having some issues connecting to LDAP through PHP. I am using the function provided here: http://www.php.net/manual/en/function.ldap-bind.php (By 'edi01 at gmx dot at'). I...
3
by: Steve Wark | last post by:
I have a Windows 2003 Web server on which I was debugging remotely with no problems. I then moved this server to a different domain and now remote debugging will not work, the error is; ...
6
by: Wardeaux | last post by:
Is there an article on how to configure Win2003 so that I can use with Visual Studio for ASP.NET development? I loaded Win2003, copied over my previous ASP.NET code, and still can't load the...
1
by: Jody Gelowitz | last post by:
We are having an issue in that when trying to read a file that is on Server2 from Server1 (through our ASP.NET project), we receive the error: Access to the path "\\Server2\MyShare\MyFile.tif" is...
4
by: klynn | last post by:
Hi: I'm having problems reading a Microsoft Access file from my ASP.Net app on a Windows Server 2003 machine. The error message: The Microsoft database engine cannot open the file, <my_file>. It...
0
by: Tom | last post by:
When I try to connect to a MS SQL Server 2000 my application always crashes (without message). In the event log I find the following error: Faulting application testapp.exe, version...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.