Search This Blog

Login Panel

Insertion of data using ADO.net( disconnected architecture)

protected void btnsubmit_Click(object sender, EventArgs e)
{
cmd.CommandText = "select * from login";
adp.Fill(ds,"vt1");
dr = ds.Tables["vt1"].NewRow();
dr["name"] = txtname.Text;
dr["age"] = Convert.ToInt32(txtage.Text);
dr["contact_no"] = Convert.ToInt64(txtcontno.Text);
dr["address"] = txtaddr.Text;
dr["email_id"] = txtemail.Text;
dr["userid"] = txtuid.Text;
dr["pwd"] = txtpwd.Text;
dr["hintq"] = DropDownList1.SelectedItem.Text.Replace("'","");
dr["ans"] = txtans.Text;
dr["imgname"] = FileUpload1.FileName;
dr["imgpath"] = "~//image/" + FileUpload1.FileName;
FileUpload1.SaveAs(Server.MapPath("~//image/" + FileUpload1.FileName));
ds.Tables["vt1"].Rows.Add(dr);
SqlCommandBuilder scb = new SqlCommandBuilder(adp);
adp.Update(ds.Tables["vt1"]);
Response.Redirect("login.aspx");

}

Login Page


protected void Button1_Click(object sender, EventArgs e)
{
cmd.CommandText = "select * from login where uid='"+txtuid.Text+"' and password='"+txtpass.Text+"'";
adp.Fill(ds,"vt");
if(ds.Tables["vt"].Rows.Count = =0)
{
lbmsg.Text="Invalid userid or password";
}
else
{
foreach(DataRow drr in ds.Tables["vt"].Rows)
{
Session["uid"]=txtuid.Text ;
break;
}
Response.Redirect("welcome.aspx");
}
}