2017-08-21 4 views
-7

こんにちはみんなはどのように私はエラーなしで写真と私のデータを更新することができ 、私のデータベース名はテーブルで、テーブルの内容がのC#: '(

  • IDです
  • 姓、
  • MiddleName、
  • 姓、
  • 性別、
  • 住所、
  • dateOfBirthの、
  • 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"); 
} 

私が参照し、DISPLAY PHOTO didntはSECOND ERROR:

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

エラーは非常に明確です - あなたは画像と呼ばれる列を話しましたが、1つはありません – BugFinder

答えて

1
+0

そのコードは私の挿入ボタンに使用されているので、何ですか? – Strudops

+0

彼の2行目には、代わりに 'images = @ images'があります。 –

+0

カラム名が 'image'だと言っているので、' image = @ images'を使う必要があるようですが、あなたが使ったカラム名が間違っているというエラーが表示されます。 –