C# 连接数据库问题,我明明指定了sa用户,但NETWORK SERVICE失败?!!
仙鹤 2004-03-23 12:39:34 我在WEB窗体中连接数据库:
<script language="C#" runat="server">
protected void Page_Load(Object sender, EventArgs e)
{
string connStr=("Data Source=192.168.0.40;Integrated Security=SSPI;Initial Catalog=pubs;User ID=sa; PassWord =sa;");
SqlConnection myConnection = new SqlConnection(connStr);
SqlDataAdapter myCommand = new SqlDataAdapter("select * from Authors", myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "作者");
MyDataGrid.DataSource=ds.Tables["作者"].DefaultView;
MyDataGrid.DataBind();
}
</script>
<body>
<h3><font face="宋体">DataGrid 控件的简单选择</font></h3>
<ASP:DataGrid id="MyDataGrid" runat="server" Width="700" BackColor="#ccccff" BorderColor="black"
ShowFooter="false" CellPadding="3" CellSpacing="0" Font-Name="宋体" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd"
EnableViewState="false" />
</body>
打开web页面提示:
Exception Details: System.Data.SqlClient.SqlException: 用户 'NT AUTHORITY\NETWORK SERVICE' 登录失败。
请高手指点,我指定了以sa用户登录,但为什么提示 用户 NETWORK SERVICE登录失败呢?