SqlConnection con = new SqlConnection("Data Source=ANKITA-USER18\\SQL2008R2;Integrated Security=True;Initial Catalog=hrdemo");
con.Open();
SqlCommand cmd = new SqlCommand("insert into emp values(@p1,@p2)", con);
cmd.Parameters.Add("@p1", SqlDbType.Int);
cmd.Parameters.Add("@p2", SqlDbType.VarChar,40);
cmd.Parameters["@p1"].Value = System.Convert.ToInt32(TextBox1.Text);
cmd.Parameters[1].Value = TextBox2.Text;
int ans = cmd.ExecuteNonQuery();
Response.Write(ans.ToString() + "records inserted");
No comments:
Post a Comment