在WIN2003 Box上连接到SQL Server [英] Connecting to SQL Server on WIN2003 Box

查看:66
本文介绍了在WIN2003 Box上连接到SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从ASP.Net页面连接到2003服务器,并且得到以下错误消息

。有人可以请帮助我开始如何跟踪并修复此错误吗?我正在使用的代码低于错误我是

获得。


错误:System.Data.SqlClient.SqlException:SQL Server不存在或

访问被拒绝。在System.Data.SqlClient.ConnectionPool.GetConnection(布尔&

isInTransaction)at

System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString

选项,布尔& isInTransaction)

System.Data.SqlClient.SqlConnection.Open()at

testbed.Navigation.Page_Load(Object sender,EventArgs e)in c:\documents和

settings\collinss \vswebcache\605webdev-2_443 \ testbed\\\
avigation.aspx.cs:line

31

private void Page_Load(object sender,System.EventArgs e)

{

//将用户代码置于此处初始化页面

SqlDataReader dataReader = null;


尝试

{

SqlConnection connection = new

SqlConnection(" Server = TestWebServer; Database = Commo n; user id = myUserID;

password = myPassword");

SqlCommand command = new SqlCommand(" ; GetNavigationMenu" ;,连接);

command.CommandType = CommandType.StoredProcedure;

connection.Open();

dataReader = command.ExecuteReader(); < (b)/ b
$ b {

string headerMenu =(string)dataReader [" HeaderMenu"];>
while(dataReader.Read())



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异常)

{

Response.Write( 错误: + exception.ToString());

返回;

}


终于

{

if(dataReader!= null)

{

dataReader.Close();

}

}

}

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();
}
}
}

推荐答案

确认您可以使用SQL中的指定用户名和密码进行连接/>
查询分析器。


我假设服务器设置为启用了SQL和集成登录,并且

您已创建指定的登录名在SQL服务器中并授予对给定数据库的

登录访问权限?


此外,为了确保您可以连接,请尝试从命令提示符

网络服务器telnet到端口1433(如果TCP / IP是你正在使用的传输)。

问候,


Arild


" Mike Collins" <弥********* @ discussions.microsoft.com>在消息中写道

news:9C ********************************** @ microsof t.com ...
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...
我正在尝试从ASP.Net页面连接到2003服务器,并且收到以下错误消息。有人可以请帮助我开始如何跟踪和修复此错误
?我使用的代码低于我得到的错误。

错误:System.Data.SqlClient.SqlException:SQL Server不存在或
访问被拒绝。
System.Data.SqlClient.ConnectionPool.GetConnection(布尔&
isInTransaction)在System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString
options,Boolean& isInTransaction)
System.Data.SqlClient.SqlConnection.Open()at
testbed.Navigation.Page_Load(Object sender,EventArgs e)in c:\documents

settings \\ collinss \vswebcache\605webdev-2_443 \ testbed \\\
avigation.aspx.cs:line
31
私有空Page_Load(对象发送者,System.EventArgs e)
{
//将用户代码置于此处初始化页面
SqlDataReader dataReader = null;

尝试
{
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异常)
{
Response.Write(" Error:" + exception.ToString());
返回;
}

最后
{
if(dataReader!= null)
{
dataReader.Close();
}
}
}
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();
}
}
}



为两个SQL设置服务器和集成登录。我不知道如何使用

a命令提示符telnet到1433端口。如果你可以提供帮助,我会试一试

。 br />

这是我之前忘记的其他信息。

1.我正在尝试从Windows XP Professional计算机连接。

2.目前服务器是使用Win 2003的Web和数据库服务器。

3.我们正在尝试在移动

页面之前开发我们的XP盒和测试项目到测试服务器。


谢谢


" Arild Bakken"写道:
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:
验证您是否可以使用SQL查询分析器中指定的用户名和密码进行连接。

我假设服务器已设置为同时使用启用了SQL和集成登录,并且您已在SQL服务器中创建了指定的登录名并授予了对给定数据库的登录访问权限吗?

另外,为了确保您能够连接,尝试从
网络服务器上的命令提示符telnet到端口1433(如果TCP / IP是你正在使用的传输)。

问候,


迈克柯林斯 <弥********* @ discussions.microsoft.com>在消息中写道
新闻:9C ********************************** @ microsof t.com。 ..
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...
我正在尝试从ASP.Net页面连接到2003服务器,并且收到以下错误消息。有人可以请帮助我开始如何跟踪和修复此错误
?我使用的代码低于我得到的错误。

错误:System.Data.SqlClient.SqlException:SQL Server不存在或
访问被拒绝。
System.Data.SqlClient.ConnectionPool.GetConnection(布尔&
isInTransaction)在System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString
options,Boolean& isInTransaction)
System.Data.SqlClient.SqlConnection.Open()at
testbed.Navigation.Page_Load(Object sender,EventArgs e)in c:\documents

settings \\ collinss \vswebcache\605webdev-2_443 \ testbed \\\
avigation.aspx.cs:line
31
私有空Page_Load(对象发送者,System.EventArgs e)
{
//将用户代码置于此处初始化页面
SqlDataReader dataReader = null;

尝试
{
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异常)
{
Response.Write(" Error:" + exception.ToString());
返回;
}

最后
{
if(dataReader!= null)
{
dataReader.Close();
}
}
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();
}
}
}




Mike,


问题源于你在ASP.NET中运行默认的

凭证。默认情况下,在ASP.NET中运行的所有代码在ASPNET本地用户下运行

。这不能访问网络资源。


为了解决这个问题,你必须冒充用户(通过

代码,或通过web.config中的声明,它拥有

网络和SQL Server的权限。


希望这会有所帮助。

-

- Nicholas Paldino [.NET / C#MVP]

- mv *@spam.guard.caspershouse.com


" Mike Collins" <弥********* @ discussions.microsoft.com>在留言中写道

新闻:D0 ********************************** @ microsof t.com ...
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...
服务器设置为SQL和集成登录。我不知道如何使用
命令提示符telnet到1433端口。如果你可以帮忙,我会试一试


以下是我之前忘记的其他信息。
1.我正在尝试从Windows XP Professional计算机连接。
2.目前服务器既是网络又是数据库使用Win 2003的服务器。
3.我们正在尝试开发我们的XP盒和测试项目,然后将
页面移到测试服务器上。

谢谢

Arild Bakken写道:
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:
验证您是否可以使用指定的用户名和密码在SQL查询分析器中进行连接。

我假设服务器是否已启用SQL和集成登录设置

您已在SQL服务器中创建指定的登录并授予对给定数据库的登录访问权限?

此外,为了确保您可以连接,请尝试从
Web服务器上的命令提示符telnet到端口1433(如果TCP / IP是您正在使用的传输)。

问候,

Arild

Mike Collins <弥********* @ discussions.microsoft.com>在消息中写道
新闻:9C ********************************** @ microsof t.com。 ..
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...
>我正在尝试从ASP.Net页面连接到2003服务器并且
>获取
>以下错误消息。有人可以帮我开始吗
>怎么
>到
>跟踪并修复此错误?我使用的代码低于我的错误
>得到。
>
>错误:System.Data.SqlClient.SqlException:SQL Server不存在或
>拒绝访问。在
>
>中的System.Data.SqlClient.ConnectionPool.GetConnection(布尔&
> isInTransaction)
> System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString
> options,Boolean& isInTransaction)
>中的System.Data.SqlClient.SqlConnection.Open()
>中的testbed.Navigation.Page_Load(Object sender,EventArgs e) c:\documents
>和
> settings \collinss \vswebcache\605webdev-2_443\testbed\\\
avigation.aspx.cs:line
> 31
>
> private void Page_Load(object sender,System.EventArgs e)
> {
> //将用户代码置于此处初始化页面
> SqlDataReader dataReader = null;
>
>试试
> {
> SqlConnection连接=新
> 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异常)
> {
> Response.Write(" Error:" + exception.ToString());
>返回;
> }
>
>终于
> {
> if(dataReader!= null)
> {
> dataReader.Close();
> }
> }
> }
>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();
> }
> }
> }




这篇关于在WIN2003 Box上连接到SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆