如何删除数据库的表

happymood 2000-06-01 10:28:00
各位大哥,我用下面的代码删除一个数据中的表,但是删不了,究竟怎么回事?
dim db as Database
..
..
db.TableDefs.Delete 表名


...全文
165 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
sillyjohn 2000-06-05
  • 打赏
  • 举报
回复
我用过,可以,所以你看一下你是否程序中有错!
happymood 2000-06-05
  • 打赏
  • 举报
回复
我试过了,用drop table 不得吃!
比如下面的语句
gdbAllList.Execute "drop table " & cmbType.Text, dbSQLPassThrough

Chen_Lin 2000-06-02
  • 打赏
  • 举报
回复
看看MS$的例子:
Sub DeleteX()

Dim dbsNorthwind As Database
Dim rstEmployees As Recordset
Dim lngID As Long

Set dbsNorthwind = OpenDatabase("Northwind.mdb")
Set rstEmployees = _
dbsNorthwind.OpenRecordset("Employees")

' Add temporary record to be deleted.
With rstEmployees
.Index = "PrimaryKey"
.AddNew
!FirstName = "Janelle"
!LastName = "Tebbs"
.Update
.Bookmark = .LastModified
lngID = !EmployeeID
End With

' Delete the employee record with the specified ID
' number.
DeleteRecord rstEmployees, lngID

rstEmployees.Close
dbsNorthwind.Close

End Sub

Sub DeleteRecord(rstTemp As Recordset, _
lngSeek As Long)

With rstTemp
.Seek "=", lngSeek
If .NoMatch Then
MsgBox "No employee #" & lngSeek & " in file!"
Else
.Delete
MsgBox "Record for employee #" & lngSeek & _
" deleted!"
End If
End With

End Sub
bokei 2000-06-02
  • 打赏
  • 举报
回复
好象要用DAO才能用drop table
zzj_mjz 2000-06-02
  • 打赏
  • 举报
回复
执行SQL语句 "drop table 表名"
jing 2000-06-02
  • 打赏
  • 举报
回复
drop

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧