我是 VB.net、sql 甚至 phpmyadmin gui 的新手。我想删除保存在 phpmyadmin 中的记录,但是在执行 sqlcommand 的 executenonquery() 时出现错误
这是我在 VB.NET 中使用的代码:
Public Sub RetrieveInfos(ByRef SQLStatement As String)
Dim cmd As MySqlCommand = New MySqlCommand
With cmd
.CommandText = SQLStatement
.CommandType = CommandType.Text
.Connection = SQLConnection
.ExecuteNonQuery()
End With
'--read the records in database in phpmyadmin gui---
Dim myReader As MySqlDataReader = cmd.ExecuteReader
If myReader.Read Then
lblName.Text = myReader.GetString(0)
lblAge.Text = myReader.GetString(1)
End If
myReader.Close()
SQLConnection.Close()
MsgBox("Records Successfully Retrieved")
SQLConnection.Dispose()
End Sub
Private Sub btnRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRefresh.Click
Dim SQLStatement As String = "DELETE FROM patient WHERE 1"
RetrieveInfos(SQLStatement)
End Sub
任何帮助,将不胜感激。谢谢!