2017-05-28 71 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的新聞以舊值回來,所以沒有更新。 –