当我尝试将图像和文本保存到SQL Server数据库时,我总是收到错误。
这是我的代码
If confirm("คุณต้องการจะเพิ่มข้อมูลหรือไม่") = vbNo Then Return
sql = "select count(*) from dataplantaev2 where loc = '" & txt_loc_save.Text & "'"
If cmd_excuteScalar() > 0 Then
error_message("ไม่สามารถเพิ่มได้ เนื่องจากมีอยู่แล้วในระบบ")
Return
End If
sql = "insert into dataplantaev2 value(@loc, @sci, @fam, @type, @seri, @loca, @dom, @pic)"
cmd = New SqlClient.SqlCommand(sql, cn)
cmd.Parameters.Clear()
cmd.Parameters.AddWithValue("loc", txt_loc_save.Text)
cmd.Parameters.AddWithValue("sci", txt_sci_save.Text)
cmd.Parameters.AddWithValue("fam", txt_fam_save.Text)
cmd.Parameters.AddWithValue("type", txt_type_save.Text)
cmd.Parameters.AddWithValue("seri", txt_seri_save.Text)
cmd.Parameters.AddWithValue("loca", txt_loca_save.Text)
cmd.Parameters.AddWithValue("dom", txt_dom_save.Text)
cmd.Parameters.AddWithValue("pic", convert_PictureBox_toDatabase(PictureBox1))
If cmd.ExecuteNonQuery > 0 Then
ok_message("เพิ่มสำเร็จ")
Else
error_message("เพิ่มไม่สำเร็จ")
End If
答案 0 :(得分:1)
让我们再试一次。 值不是值:
sql = "INSERT INTO dataplantaev2 VALUES(@loc, @sci, @fam, @type, @seri, @loca, @dom, @pic)"