Hi there, in the following code, I am trying to connect to my sql server from C# aspx code. However, when I run it, i seem to get the following error.
In my sql server security/login setting, I have testuser to access the Northwind db and permit db role as public.
any sort of input is greately appriciated!
thanks
Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
Source Error:
Line 11:
Line 12: DataSet ds = new DataSet();
Line 13: myCommand.Fill(ds, "Orders");
Line 14:
Line 15: MyDataGrid.DataSource=ds.Tables["Orders"].DefaultView;
In my sql server security/login setting, I have testuser to access the Northwind db and permit db role as public.
any sort of input is greately appriciated!
thanks
Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
Source Error:
Line 11:
Line 12: DataSet ds = new DataSet();
Line 13: myCommand.Fill(ds, "Orders");
Line 14:
Line 15: MyDataGrid.DataSource=ds.Tables["Orders"].DefaultView;
Code:
<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<script language="C#" runat="server">
protected void Page_Load(Object sender, EventArgs e) {
SqlConnection myConnection = new SqlConnection("Database=Northwind;Server=localhost;In\
tegrated Security=SSPI; User ID=KKCOMPUTER\\testuser; Password=passwd");
SqlDataAdapter myCommand = new SqlDataAdapter("select * from Orders", myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "Orders");
MyDataGrid.DataSource=ds.Tables["Orders"].DefaultView;
MyDataGrid.DataBind();
}
</script>
<body>
<h3><font face="Verdana">Simple Select to a DataGrid Control</font></h3>
<ASP:DataGrid id="MyDataGrid" runat="server"
Width="700"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false"
/>
</body>
</html>