A ) WEB FORM NORMAL PAGE (INSERT , FIND , UPDATE , DELETE)
* NORMAL PAGE (INSERT , FIND , UPDATE , DELETE) *
Q ) How to normal insert data with parameter .
string path = @"Data Source=.\SQLEXPRESS;Initial Catalog=vnit;Integrated Security=True";
cn = new SqlConnection(path);
cn.Open();
string k = " insert into demobb(roll,name,city,email) values(@roll1,@name1,@city1,@email1)";
cm = new SqlCommand(k, cn);
cm.Parameters.AddWithValue("roll1", txtroll.Text);
cm.Parameters.AddWithValue("name1", txtname.Text);
cm.Parameters.AddWithValue("city1", ddlcity.Text);
cm.Parameters.AddWithValue("email1", txtemail.Text);
ddlcity.Items.Insert(0,"select");
cm.ExecuteNonQuery();
Response.Write("<script language='JavaScript'>alert('record submited')</script>");
FIND
Q ) How to FIND data with parameter .
string path = @"Data Source=.\SQLEXPRESS;Initial Catalog=vnit;Integrated Security=True";
cn = new SqlConnection(path);
cn.Open();
string k = "select * from demobb where roll=@roll1 ";
cm = new SqlCommand(k, cn);
cm.Parameters.AddWithValue("roll1", txtroll.Text);
dr = cm.ExecuteReader();
if (dr.Read())
{
txtname.Text=dr["name"].ToString();
ddlcity.Text=dr["city"].ToString();
txtemail.Text=dr["email"].ToString();
Response.Write("data find succesfully");
}
else
{
Response.Write("data not found");
}
dr.Close( );
UPDATE
Q ) How to Update data with parameter .
string path = @"Data Source=.\SQLEXPRESS;Initial Catalog=vnit;Integrated Security=True";
cn = new SqlConnection(path);
cn.Open();
string k = "update demobb set name=@name1,email=@email1 where roll=@roll1 ";
cm = new SqlCommand(k, cn);
cm.Parameters.AddWithValue("roll1", txtroll.Text);
cm.Parameters.AddWithValue("name1", txtname.Text);
cm.Parameters.AddWithValue("email1", txtemail.Text);
cm.ExecuteNonQuery();
Response.Write("data updated succesfully");
DELETE
Q ) How to Delete data with parameter .
string path = @"Data Source=.\SQLEXPRESS;Initial Catalog=vnit;Integrated Security=True";
cn = new SqlConnection(path);
cn.Open();
string k = "delete from demobb where roll=@roll1 ";
cm = new SqlCommand(k, cn);
cm.Parameters.AddWithValue("roll1", txtroll.Text);
cm.ExecuteNonQuery();
Response.Write("data deleted succesfully");
All include normal data in one video (insert ,update,delete,find)
Comments
Post a Comment