[英]vb.net(Additional information: Unknown column 'Secret_question' in 'where clause')
[英]vb.net and mysql 'unknown column (*'firstletter of selected row in column idb that i made'*) in where clause
我正在尝试删除选定的行,但是当我单击按钮删除时,它给了我一个警告
where 子句中的“未知列”c。
实际上不仅是那些行,而且每一行都在 where 子句中选择了“未知列”( “我创建的列idb 中选定行的第一个字母” )。
这是我的代码。
公开课
Public Class DAFTAR_BUKU
Dim Koneksi As New MySqlConnection
Dim da As MySqlDataAdapter
Dim ds As New DataSet
Dim dt As New DataTable
Dim command As MySqlCommand
Dim id_cell As Char
Dim i As Integer
Dim query As String
用于函数删除
Private Sub delete(kdbk As Char)
Dim query As String = "delete from daftarbuku where idb= " & kdbk
command = New MySqlCommand(query, Koneksi)
Try
Koneksi.Open()
da.DeleteCommand = Koneksi.CreateCommand()
da.DeleteCommand.CommandText = query
If MessageBox.Show("sure", "delete", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.OK Then
If command.ExecuteNonQuery() > 0 Then
MsgBox("DELETED")
cleartext()
End If
End If
Koneksi.Close()
DataGridView1.Rows.RemoveAt(i)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
用于按钮删除
Private Sub del_Click(sender As Object, e As EventArgs) Handles del.Click
delete(id_cell)
GRID()
End Sub
根据您的代码,我假设列idb是整数。 因此,您将整数传递给接受char的函数。
您可以将 char 更改为 integer 或将id_cell
更改为id_cell.tostring
。
同样在您使用 mysql 的 catch 异常中,使用ex as MySqlException
并在 MessageBox 中使用MsgBox(ex.toString)
。
你可以从下一次显示的详细异常错误中更好地理解。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.