如何利用SQL中的Delete语句删除数据(Access)

yoyodd 2003-12-10 04:57:55
如何利用SQL中的Delete语句删除数据(Access)
表 student
...全文
1294 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
cloudtarget 2004-02-07
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/2098/2098925.xml?temp=.3121912
yoyodd 2003-12-10
  • 打赏
  • 举报
回复
我用jet数据源
我要用delete删除一个name='cjx'的记录
如何执行啊?
leecooper0918 2003-12-10
  • 打赏
  • 举报
回复

'truncate table tablename' is much faster than 'delete from tablename'.
dengyiwolf 2003-12-10
  • 打赏
  • 举报
回复
delete from students (删除整个表的记录)
delete from students where student_ID='' (删除满足条件的记录)
aoenzh 2003-12-10
  • 打赏
  • 举报
回复
Dim conn As ADODB.Connection
conn.Open "Provider=sqloledb;" & _
"Data Source=srv;Initial Catalog=pubs;User Id=sa;Password=; "

conn.execute "delete from students"
yoki 2003-12-10
  • 打赏
  • 举报
回复
conn.execute "delete from students"
303 2003-12-10
  • 打赏
  • 举报
回复

楼上三位都说了,还不可以吗?
SoHo_Andy 2003-12-10
  • 打赏
  • 举报
回复
在Access中删除记录
不加where 条件语句则删除表中全部内容
Sub DeleteX()

Dim dbs As Database, rst As Recordset

' 在您的计算机中修改此行使其正确指到 Northwind 的路径。
Set dbs = OpenDatabase("Northwind.mdb")

' 删除员工职称为 Trainee 的员工记录。
dbs.Execute "DELETE * FROM " _
& "Employees WHERE Title = 'Trainee';"

dbs.Close

End Sub
SoHo_Andy 2003-12-10
  • 打赏
  • 举报
回复
'删除整个表
Sub DropX2()
Dim dbs As Database
'在您的计算机中修改此行使其正确指到 Northwind 的路径。
Set dbs = OpenDatabase("Northwind.mdb")
' 删除员工表。
dbs.Execute "DROP TABLE Employees;"
dbs.Close
End Sub

'删除记录的两个例子
1、
Public Sub DeleteX()
Dim rstRoySched As ADODB.Recordset
Dim strCnn As String

strCnn = "Provider=sqloledb;" & _
"Data Source=srv;Initial Catalog=pubs;User Id=sa;Password=; "

Set rstRoySched = New ADODB.Recordset
rstRoySched.CursorLocation = adUseClient
rstRoySched.CursorType = adOpenKeyset
rstRoySched.LockType = adLockOptimistic

rstRoySched.Open "SELECT * FROM roysched " & _
"WHERE royalty = 20", strCnn, , , adCmdText

' Delete the record.
rstRoySched.Delete
rstRoySched.Update

rstRoySched.Close

End Sub
2、
Public Sub DeleteX()
Dim cnn As ADODB.Connection
cnn.Open "Provider=sqloledb;" & _
"Data Source=srv;Initial Catalog=pubs;User Id=sa;Password=; "
cnn.execute "delete form 表 where id=2"

End Sub
ZQY801105 2003-12-10
  • 打赏
  • 举报
回复
Delete from student
注意:要加上from,这是access与SQL Server的不同之处!
试试吧,老兄,祝你好运!
对了,别忘了给分呀!

1,216

社区成员

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

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