2012-07-26 64 views
2

我是新的VB.net,SQL和甚至phpmyadmin貴。我想刪除保存在我的phpmyadmin記錄,但執行的SqlCommand的的ExecuteNonQuery()時,我得到了一個錯誤如何刪除phpmyadmin中的數據庫記錄?

這是在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 

任何幫助,將不勝感激。謝謝!

+0

phpmyadmin是一個用於使用MySQL數據庫而不是數據庫服務器的GUI工具。 – 2012-07-26 17:12:00

+0

'我想...但是我得到了錯誤'錯誤是什麼? – Ghost 2012-07-26 17:12:29

+0

你確定錯誤來自'executivetenonquery'而不是'executereader'嗎? – Ghost 2012-07-26 17:15:56

回答

1

要刪除phpmyadmin中的數據,請按照phpMyAdmin setting的規定,您需要在config.inc.php中進行編輯。

boolean $cfg['AllowUserDropDatabase'] (line 503) 

show a 'Drop database' link to normal users