Hi friends
i want to develop login control with asp.net ,c#, sql server 2005.
- how i check the TextBox it is validate or not by coding
- if click on button then user id & password match to textboxes and new default .aspx page should be open . i can't do next coding exccept it :-
string myConnectString = "Data Source=NBAP25169578480;Initial Catalog=employee;Integrated Security=True";
SqlConnection con = new SqlConnection(myConnectString);
SqlCommand cmd = new SqlCommand("select * from emp where userid = @userid , password = @password ",con);
cmd.CommandType =
CommandType.Text;cmd.Connection = con;
cmd.Parameters.Add (
"@userid",TextBox1.Text );cmd.parameter.Add("@password , TextBox2.Text"); // how i can open new page
cmd.Connection.Open();
cmd.ExecuteNonQuery();
con.Close();
ArshadPosted Jul 18, 2008, 5:51 AM
Try to to some thing Like that
string myConnectString = "Data Source=NBAP25169578480;Initial Catalog=employee;Integrated Security=True";
SqlConnection con = new SqlConnection(myConnectString);
SqlCommand cmd = new SqlCommand("select * from emp",con);
//After That Use the Adapter and fill the Dataset with that //table Then
SqlDataAdapter da=new SqlDataAdapter();
DataSet ds =new DataSet();
da.Fill(ds);
if(ds.Tables(0).Rows(0).Item("UserID")=txtUserId.Text)and
(ds.Tables(0).Rows(0).Item("password")=txtPassword.Text)
{Response.Redirect("Home.aspx");
}
This is not very Standard, but for ur reference i have give some thing Like that,Just test it i dint test it May be it can give some Error. but Logic is Correct.But Instead of DataSet try to use DataReader coz its Read only and forword Only.Thats All, thanks