CodeFile
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient ;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class UpdateRecord : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Trusted_Connection=true; DataBase=Praveen_DataBase");
SqlCommand cmd = new SqlCommand("update Table1 set Name=@Name,Address=@Address,Course=@Course where Roll=@Roll ", con);
SqlParameter obj1 = new SqlParameter("@Name", DbType.StringFixedLength);
obj1.Value = TextBox1.Text;
cmd.Parameters.Add(obj1);
SqlParameter obj2 = new SqlParameter("@Address", DbType.StringFixedLength);
obj2.Value = TextBox2.Text;
cmd.Parameters.Add(obj2);
SqlParameter obj3 = new SqlParameter("@Course", DbType.StringFixedLength);
obj3.Value = TextBox3.Text;
cmd.Parameters.Add(obj3);
SqlParameter obj4 = new SqlParameter("@Roll", DbType.Int32.ToString());
obj4.Value = TextBox4.Text;
cmd.Parameters.Add(obj4);
con.Open();
cmd.ExecuteNonQuery();
Label1.Text = "Record updated";
con.Close();
}
}
0 comments:
Post a Comment