using System; using System.Collections; using System.Configuration; using System.Data; 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; using System.Data.SqlClient; public partial class _22 : System.Web.UI.Page { SqlConnection conn = null; protected void Page_Load(object sender, EventArgs e) { if (Session["user"] == null) { Response.Redirect("MainLogin.aspx"); } } protected void Button2_Click(object sender, EventArgs e) { if (Button2.Text == "edit") { UpdateData(); } } private void UpdateData() { // SqlConnection conn = null; SqlCommand cmd = null; try { conn = new SqlConnection(ConfigurationManager.ConnectionStrings["PConnStr"].ConnectionString); string sql = "Update ABC set name=@name,age=@age where name=@a"; conn.Open(); cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@name", TextBox1.Text); cmd.Parameters.AddWithValue("@age", TextBox2.Text); cmd.Parameters.AddWithValue("@a", Session["name"]); cmd.ExecuteNonQuery(); Label3.Visible = true; Label3.Text = "Updated Successfully"; } catch (Exception ex) { Label4.Text = ex.ToString(); Label4.Visible = true; } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } } } protected void Button1_Click(object sender, EventArgs e) { SqlDataAdapter da = null; DataSet dsUser = null; SqlDataReader dr; try { conn = new SqlConnection(ConfigurationManager.ConnectionStrings["PConnStr"].ConnectionString); conn.Open(); string sql = "Select * from ABC,Login where name=@name and Password=@pswd"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@name", Session["user"]); cmd.Parameters.AddWithValue("@pswd", Session["pswd"]); //cmd.Parameters.AddWithValue("@lname",T2.Text); // cmd.Parameters.AddWithValue("@p_id", cmbP_id.Text); dr = cmd.ExecuteReader(); if (dr.Read()) { TextBox1.Text = dr[2].ToString(); TextBox2.Text = dr[3].ToString(); TextBox3.Text = dr[4].ToString(); } } catch (Exception ex) { Label3.Text = ex.ToString(); Label3.Visible = true; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)