learner

learner

  • NA
  • 11
  • 0

asp.net (C#)-simple Login page

Nov 24 2009 12:32 PM
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?

Answers (3)