数据库连接成功后,清除数据库内容出错!
Dim MyCon As New OleDbConnection
Dim MyCmd As New OleDbCommand
MyCon.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=D:\vbprint\lpjk.mdb "
MyCon.Open()
MyCmd.Connection = MyCon
MyCmd.CommandText = "delete from yw_95tmp"
MyCmd.ExecuteNonQuery() '''此处报错,提示信息是无法删除!郁闷中。。。。请高手指点!感谢!
MyCon.Close()
[解决办法]
直接用Mycon.excute 跟sql语句,不就行了,必须要用command吗?
[解决办法]
"delete * from yw_95tmp"
[解决办法]
delete 语句不需要 *
试试
Dim MyCon As New ADODB.Connection
MyCon.Open "provider=microsoft.jet.oledb.4.0;data source=D:\vbprint\lpjk.mdb"
MyCom.Execute "delete from yw_95tmp"
MyCon.Close()
表 yw_95tmp 是否存在?
[解决办法]
如果不能确保表 yw_95tmp 存在,在 Delete 语句前加上:
On Error Resume Next