查询记录集
像这样的记录集查询是否有效
rs.open "select * from table where vd=1; update table set vd1 = 1 where vd=2 or vd=3;"
或者有什么问题吗
谢谢
Will a query like this on a recordset work
rs.open "select * from table where vd=1; update table set vd1 = 1 where vd=2 or vd=3;"
or is there anything wrong
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它不会工作 - 您必须将它们作为单独的命令执行
大概您已将
rs
声明为记录集,因此您可以使用它来返回SELECT
语句结果。我将使用 SQL 命令来执行第二条语句。
It won't work - you'll have to execute them as separate commands
Presumably you've declared
rs
as a recordset, so you can use that to return theSELECT
statement results.I would use a SQL command to execute the second statement.
记录集只能使用单个 SELECT 语句来定义(当然,如果多个选择具有相同的列数,则可以对它们进行 UNION 操作)。
任何操作 SQL(INSERT、UPDATE、DELETE)都不能使用记录集执行,只能使用 .Execute 方法执行。
如果您使用 ADO,.Execute 也可用于 SELECT(它返回行),但 Jet 的本机数据接口层 DAO 不能 - .Execute 仅适用于操作查询。 这对我来说似乎很明智,但就我个人而言,ADO 对我来说总是浪费时间。
此外,Jet(Access 默认使用的数据库引擎)无法像许多基于服务器的数据库引擎一样同时执行多个 SQL 语句。 对于那些习惯于批处理 SQL 语句的人来说,这并不是一个很大的限制——只是不同而已。
A recordset can only be defined with a single SELECT statement (though, of course, you can UNION multiple selects if they have the same number of columns).
Any action SQL (INSERT, UPDATE, DELETE) cannot be executed with a recordset, but by using the .Execute method.
If you're using ADO, .Execute can also be used for SELECTs (it returns the rows), but Jet's native data interface layer, DAO, cannot -- .Execute works only for action queries. This seems sensible to me, but then, ADO has always seemed like a waste of time to me, personally.
Also, Jet (the db engine used by default by Access) cannot execute multiple SQL statements at once as many server-based db engines can. This is not such a big limitation as it might seem to those accustomed to batching SQL statements -- it's just different.