您好我正在尝试使用excel中的vba删除mysql数据库中的所有行。 我现在尝试了很多代码,并且我得到的最接近的代码是以下代码,但我仍然遇到语法错误:
rsmysql.Open rsstr, coninc
有人可以帮我纠正代码,所以我可以让它工作。
Dim rsmysql As ADODB.Recordset 'Holds records
Dim rsstr As String
Dim coninc As String
Set cnmysql = New ADODB.Connection
Set rsmysql = New ADODB.Recordset
coninc = "Driver={MySQL ODBC 5.3 ANSI Driver};Server=" & _
Server_Name & ";Database=" & Database_Name & _
";Uid=" & User_ID & ";Pwd=" & Password & ";"
rsstr = "delete * from TLHMember_List;"
cnmysql.Open coninc
rsmysql.Open rsstr, coninc
MsgBox "Data has been deleted"
Exit Sub
答案 0 :(得分:0)
rsstr = "delete from TLHMember_List"
cnmysql.Open coninc
cnmysql.Execute rsstr
MsgBox "Data has been deleted"