i am getting problem in connecting my asp.net(c#) web application with Sql Server 2000 programatically on the page load of my web form
I wrote following code in the page load
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page
SqlConnection myConnection = new SqlConnection("server=(local);database=master;Integrated Security=SSPI");
SqlDataAdapter myCommand = new SqlDataAdapter("select * from emp", myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "emp");
DataGrid1.DataSource=ds.Tables["emp"].DefaultView;
DataGrid1.DataBind();
}
Build OK but following exception occurred:
Server Error in '/datagridtest' Application.
------------------------
Login failed for user 'MATRIX\ASPNET'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'MATRIX\ASPNET'.
Source Error:
Line 27:
Line 28: DataSet ds = new DataSet();
Line 29: myCommand.Fill(ds, "emp"); //THIS APPEARS IN RED ON THE PAGE
Line 30:
Line 31: DataGrid1.DataSource=ds.Tables["emp"].DefaultView;
----------------------------
PLZ HELP ME, I THINK THE PROBLEM IS WITH CONNECTIONSTRING, I STUCK UP HERE FROM LAST 3 DAYS AND COULD NOT PROCEED WITH MY FURTHER STUDY AND PRACTICE
THANX IN ADVANCE
BSSGlad you got this worked out!view post 806235
No comments:
Post a Comment