2017-05-28 78 views
-1

我带来了签名者信息。更新时出现问题。如何更新会话

这里我的代码:

OleDbConnection baglanti = new OleDbConnection("Provider=Microsoft.jet.OLEDB.4.0;Data Source=" + HttpContext.Current.Server.MapPath("~/App_Data/Database.mdb")); 
protected void Page_Load(object sender, EventArgs e) 
{ 
    baglanti.Open(); 
    var ID = Session["id"]; 
    OleDbCommand komut = new OleDbCommand("select *from tablo1 where id=" + ID + "", baglanti); 
    komut.Parameters.AddWithValue("id", TextBox6.Text); 
    OleDbDataReader oku = komut.ExecuteReader(); 

    if (oku.Read()) 
    { 
     TextBox1.Text = oku["isim"].ToString(); 
     TextBox2.Text = oku["soyisim"].ToString(); 
     TextBox3.Text = oku["kadi"].ToString(); 
     TextBox4.Text = oku["sifre"].ToString(); 
     TextBox5.Text = oku["email"].ToString(); 
    } 
} 

,并

protected void Button1_Click(object sender, EventArgs e) 
{ 
    //update 
    var ID = Session["id"]; 
    OleDbCommand komut = new OleDbCommand("update tablo1 set [email protected],[email protected],[email protected],[email protected],[email protected] where id=" + ID + "", baglanti); 
    komut.Parameters.AddWithValue("@isim", TextBox1.Text); 
    komut.Parameters.AddWithValue("@soyisim", TextBox2.Text); 
    komut.Parameters.AddWithValue("@kadi", TextBox3.Text); 
    komut.Parameters.AddWithValue("@sifre", TextBox4.Text); 
    komut.Parameters.AddWithValue("@email", TextBox5.Text); 
    komut.ExecuteNonQuery(); 
    baglanti.Close(); 
} 

不updating.I我选择datas.But的button1_Click犯规工作。

+0

** **警告你的代码很容易受到SQL注入攻击。 –

回答

0

真的索里我没有阅读后仔细 在第一页面加载事件中添加以下代码

if (!IsPostBack) 
    { 
     return; 
    } 
+0

谢谢你的帮助。它的工作。 –

0

我不明白你的问题是如何更新会话或的button1_Click不工作

所以她这

更新会话使用(会话[ “ID”] = theNewValue;)

对于按钮事件没有阻止请求粘贴在这里从设计页面的按钮标签

+0

我正在改变这个值,但是butona的新闻以旧值回来,所以没有更新。 –