2017-08-21 25 views
-7

嗨,大家好我如何與照片更新我的數據沒有錯誤 我的數據庫名字爲表和表的內容是C#如何與照片尋找一些幫助,瞭解更新的數據:'(

  • ID,
  • 名字,
  • 中間名,
  • 姓氏,
  • 性別,
  • 地址,
  • 出生日期,
  • PlaceofBirth,
  • FathersName,
  • FathersOccupation,
  • MothersName,
  • MothersOccupation,
  • 監護人,
  • 關係,
  • GuardianOccupation,
  • 圖像,

我編輯了一些數據,但是,這是出現的時候,我改變/編輯它,我該如何解決這個:

enter image description here

private void button3_Click(object sender, EventArgs e) 
{ 
    byte[] images = null; 
    FileStream fs = new FileStream(img, FileMode.Open, FileAccess.Read); 
    BinaryReader br = new BinaryReader(fs); 
    images = br.ReadBytes((int)fs.Length); 

    con.Open(); 

    string sql = "update table1 set [email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],@images=images where [email protected]"; 

    cmd = new SqlCommand(sql, con); 
    cmd.Parameters.Add(new SqlParameter("@id", textBox1.Text)); 
    cmd.Parameters.Add(new SqlParameter("@FirstName", textBox2.Text)); 
    cmd.Parameters.Add(new SqlParameter("@MiddleName", textBox3.Text)); 
    cmd.Parameters.Add(new SqlParameter("@LastName", textBox4.Text)); 
    cmd.Parameters.Add(new SqlParameter("@Gender", comboBox1.Text)); 
    cmd.Parameters.Add(new SqlParameter("@DateofBirth", dateTimePicker1.Value.ToString())); 
    cmd.Parameters.Add(new SqlParameter("@PlaceofBirth", textBox5.Text)); 
    cmd.Parameters.Add(new SqlParameter("@Address", textBox6.Text)); 
    cmd.Parameters.Add(new SqlParameter("@FathersName", textBox7.Text)); 
    cmd.Parameters.Add(new SqlParameter("@FathersOccupation", textBox8.Text)); 
    cmd.Parameters.Add(new SqlParameter("@MothersName", textBox9.Text)); 
    cmd.Parameters.Add(new SqlParameter("@MothersOccupation", textBox10.Text)); 
    cmd.Parameters.Add(new SqlParameter("@Guardian", textBox11.Text)); 
    cmd.Parameters.Add(new SqlParameter("@Relation", textBox12.Text)); 
    cmd.Parameters.Add(new SqlParameter("@GuardianOccupation", textBox13.Text)); 
    cmd.Parameters.Add(new SqlParameter("@images", images)); 

    int n = cmd.ExecuteNonQuery(); 
    con.Close(); 

    viewlist(); 
    MessageBox.Show(n.ToString() + "Update Successfull"); 
} 

第二錯誤時,我並沒有瀏覽和顯示圖片:

The SECOND ERROR WHEN I DIDNT BROWSE AND DISPLAY PHOTO

+2

發佈您的代碼,而不是像 –

+2

歡迎堆棧溢出!在提問之前請[請閱讀此](https://stackoverflow.com/help/how-to-ask)。 \t 請編輯並提供[最小,完整和可驗證示例](https://stackoverflow.com/help/mcve)您的問題 –

+1

錯誤非常明顯 - 您曾經談到過一個名爲圖像的列 - 並且沒有一個 – BugFinder

回答

1
+0

什麼是解決方案先生,因爲該代碼是我用我的插入按鈕 – Strudops

+0

在他的第二行,他有'圖像= @圖像'而不是。 –

+0

雖然,聽起來你需要使用'image = @ images',因爲你說列名是'image',並且錯誤告訴你你使用的列名是不正確的。 –