Saturday 10 December 2011

Check If A Login Exists:Using ExecuteScalar() & ExecuteReader()

ExecuteScalar And ExecuteReader Use In Checking Login Existence 

In One Of  My Previous Blog I'v Already tought you About


Execute Scaler Use To Count Rows
Now Here We Basicly Deal With ExecuteScalar And ExecuteReader Use In Checking Login Existence



1)Check On Create Login If Any One Already Existed:by ExecuteScalar

SqlCommand cmd=new .......

Object obj=cmd.ExecuteScalar();
if(Obj!=null)
{
//alert (user alerready Existed)
}



2)Check On Login If SomeOne Existed Or Not


SqlCommand cmd=new .......
SqlDataReader dr=cmd.ExecuteReader()
if(dr.HasRows)
{
dr.Read();
if(dr["Username"].ToString()==TextBox1.Text && dr["Password"].ToString()==TextBox2.Text )
{
//Welcome User
}


}

1 comment:

Print Only Grid View in ASP.net

ASP.net How to Print Only GridView < div id ="gridviewDiv" >   < asp:GridView ID ="gridViewToPri...