[英]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.