主题:请大家帮个忙哈,删除数据库中的表,我的代码哪里不对?
Private Sub Form_Load()
Dim cn As New ADODB.Connection, rs As New ADODB.Recordset
Dim strquery As String
Dim sql As String
Dim strcon As String
strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source =" + "C:\Warehouses\GanSuDXT.mdb;"
cn.Open strcon
strquery = "select * from MyTable "
rs.Open strquery, cn, adOpenKeyset, adLockOptimistic
If Not rs.EOF Then
MsgBox "MyTable已经存在!"
sql = "drop Table MyTable"
con.Execute sql
Else
MsgBox "MyTable不存在!"
End If
End Sub
MyTable在 GanSuDXT.mdb里
Dim cn As New ADODB.Connection, rs As New ADODB.Recordset
Dim strquery As String
Dim sql As String
Dim strcon As String
strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source =" + "C:\Warehouses\GanSuDXT.mdb;"
cn.Open strcon
strquery = "select * from MyTable "
rs.Open strquery, cn, adOpenKeyset, adLockOptimistic
If Not rs.EOF Then
MsgBox "MyTable已经存在!"
sql = "drop Table MyTable"
con.Execute sql
Else
MsgBox "MyTable不存在!"
End If
End Sub
MyTable在 GanSuDXT.mdb里