本人机子 WIN XP PRO 操作系统
IIS 5.0 ,IE 6.0 ,SQL SERVER 2000 个人版(因为XP就只能装这个版本,不知道为什么)
Visual Studio.net 2002版,其他所有支持.NET技术的语言都安装了
还装了 .NET SDK Framwork 和 MDAC 2.7
--------------------------------------------------------------------------------
可以运行ASP文件,ADO也支持,ASPX文件也可以,但是只要一连接数据库就有问题
--------------------------------------------------------------------------------
其中一个错误页面的代码如下:
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<HTML>
<HEAD>
<title>SQL_TEST</title>
<script language="C#" runat="server">
public SqlDataReader myReader;
public string html;
protected void Page_Load(object src, EventArgs E)
{
SqlConnection mySqlConnection = new SqlConnection("user id=sa;password=;initial catalog=northwind;data source=localhost;Connect Timeout=30");
SqlCommand mySqlCommand = new SqlCommand("select * from Categories",mySqlConnection);
//SqlDataReader myReader;
//string html;
//mySqlConnection.Open();
//myReader = mySqlCommand.ExecuteReader();
try
{
mySqlConnection.Open();
myReader = mySqlCommand.ExecuteReader();
html = "<table>";
html += "<tr>";
html += "<td><b>Customer ID</b></td>";
html += "<td><b>Company Name</b></td>";
html += "</tr>";
while(myReader.Read())
{
html += "<tr>";
html += "<td>" + myReader["CustomerID"].ToString() + "</td>";
html += "<td>" + myReader["CompanyName"].ToString() + "</td>";
html += "</tr>";
}
html += "</table>";
}
catch(Exception e)
{
html = e.ToString();
}
finally
{
//myReader.Close();
mySqlConnection.Close();
}
Response.Write(html);
}
</script>
</HEAD>
<body>
<FONT face="宋体"></FONT>
</body>
</HTML>
--------------------------------------------------------------------------------
显示错误:
System.Data.SqlClient.SqlException: SQL Server 不存在或访问被拒绝。 at System.Data.SqlClient.SqlConnection.Open() at ASP.WebForm4_aspx.Page_Load(Object src, EventArgs E) in d:\inetpub\wwwroot\asp_net_1\sql_test1\WebForm4.aspx:line 21
--------------------------------------------------------------------------------
为什么,请大家指点~~
IIS 5.0 ,IE 6.0 ,SQL SERVER 2000 个人版(因为XP就只能装这个版本,不知道为什么)
Visual Studio.net 2002版,其他所有支持.NET技术的语言都安装了
还装了 .NET SDK Framwork 和 MDAC 2.7
--------------------------------------------------------------------------------
可以运行ASP文件,ADO也支持,ASPX文件也可以,但是只要一连接数据库就有问题
--------------------------------------------------------------------------------
其中一个错误页面的代码如下:
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Data" %>
<HTML>
<HEAD>
<title>SQL_TEST</title>
<script language="C#" runat="server">
public SqlDataReader myReader;
public string html;
protected void Page_Load(object src, EventArgs E)
{
SqlConnection mySqlConnection = new SqlConnection("user id=sa;password=;initial catalog=northwind;data source=localhost;Connect Timeout=30");
SqlCommand mySqlCommand = new SqlCommand("select * from Categories",mySqlConnection);
//SqlDataReader myReader;
//string html;
//mySqlConnection.Open();
//myReader = mySqlCommand.ExecuteReader();
try
{
mySqlConnection.Open();
myReader = mySqlCommand.ExecuteReader();
html = "<table>";
html += "<tr>";
html += "<td><b>Customer ID</b></td>";
html += "<td><b>Company Name</b></td>";
html += "</tr>";
while(myReader.Read())
{
html += "<tr>";
html += "<td>" + myReader["CustomerID"].ToString() + "</td>";
html += "<td>" + myReader["CompanyName"].ToString() + "</td>";
html += "</tr>";
}
html += "</table>";
}
catch(Exception e)
{
html = e.ToString();
}
finally
{
//myReader.Close();
mySqlConnection.Close();
}
Response.Write(html);
}
</script>
</HEAD>
<body>
<FONT face="宋体"></FONT>
</body>
</HTML>
--------------------------------------------------------------------------------
显示错误:
System.Data.SqlClient.SqlException: SQL Server 不存在或访问被拒绝。 at System.Data.SqlClient.SqlConnection.Open() at ASP.WebForm4_aspx.Page_Load(Object src, EventArgs E) in d:\inetpub\wwwroot\asp_net_1\sql_test1\WebForm4.aspx:line 21
--------------------------------------------------------------------------------
为什么,请大家指点~~
还是一样的错误哈
我的aspx文件是可以运行的,其他的类都可以用,可是就是用 SqlClient 和 OleDb 就不行了
怎么设置 混合模式??
把密码填在后面就可以的。password = 123456
"data source=TKCHEN;initial catalog=northwind;integrated security=SSPI;persist security info=False;workstation id=TKCHEN;packet size=4096"
后出现
System.Data.SqlClient.SqlException: 用户 'TKCHEN\ASPNET' 登录失败。 at System.Data.SqlClient.SqlConnection.Open() at ASP.WebForm4_aspx.Page_Load(Object src, EventArgs E) in d:\inetpub\wwwroot\asp_net_1\sql_test1\WebForm4.aspx:line 22
而改成(加了一个server=.;)
也和上面的错误一样啊
加了那密码也一样的啊
我直接用private void Page_Load(object sender, System.EventArgs e)
{
string connectionString = "user id=sa;password=;initial catalog=northwind;data source=localhost;Connect Timeout=30";
SqlConnection myConnection = new SqlConnection(connectionString);
myConnection.Open();
myConnection.Close();
}
都会错啊
错误是
---------------------------------------------------------------------------------------
“/asp_net_1/sql_test1”应用程序中的服务器错误。
--------------------------------------------------------------------------------SQL Server 不存在或访问被拒绝。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: SQL Server 不存在或访问被拒绝。源错误:
行 22: string connectionString = "user id=sa;password=;initial catalog=northwind;data source=localhost;Connect Timeout=30";
行 23: SqlConnection myConnection = new SqlConnection(connectionString);
行 24: myConnection.Open();
行 25: myConnection.Close();
行 26: }
源文件: d:\inetpub\wwwroot\asp_net_1\sql_test1\webform7.aspx.cs 行: 24 堆栈跟踪:
[SqlException: SQL Server 不存在或访问被拒绝。]
System.Data.SqlClient.SqlConnection.Open() +761
sql_test1.WebForm7.Page_Load(Object sender, EventArgs e) in d:\inetpub\wwwroot\asp_net_1\sql_test1\webform7.aspx.cs:24
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +29
System.Web.UI.Page.ProcessRequestMain() +724