473,221 Members | 2,111 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,221 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 1402
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: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.