asp.net (C#)-simple Login page
Hi friends,
i have created a simple login page with ASp.Net(C#)web application.
I have 2 txtbox for userid and password,and 1 buuton for submit.
i created a database NorthWind and a table Usertbl with 3 coumns (Usedid,username,Password)and added Admin as username and password manually.
im getting error msg as some SQLException.
My Web.config is
And code is now
protected void Button1_Click1(object sender, EventArgs e)
{
SqlConnection myConn = new SqlConnection(ConfigurationManager.AppSettings["strConn"]);
SqlCommand myCmd = new SqlCommand("select UserName, password from Usertbl where UserName='"+TextBox1.Text+"' and password='"+TextBox2.Text+"'", myConn);
myCmd.Connection = myConn;
myConn.Open();
SqlDataReader rdLogin = myCmd.ExecuteReader();
if (rdLogin.HasRows)
{
Response.Redirect("abc.aspx", false);
}
else
{
Lblerror1.Text = "Invalid User Id / Password";
}
myConn.Close();
}
But Im getting error in myConn.Open();
Error is
SQLException was handled by user code.( A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server))
How to proceedd?
Baimey RajeshPosted Nov 24, 2009, 12:42 PM
learnerPosted Nov 27, 2009, 1:15 PM
Amit ChoudharyPosted Nov 25, 2009, 7:32 AM
Check your Server is running or not... then check you have mentioned server's name prorperly in the connection string.... and if all are ok then go to Surface Area Configruation and then change you setting for allow remote connections to-> "TCP/IP and NamedPipes Both" check this option.....
i think it may help you to come out of your problem....
Please mark the answer if it helps :)