您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

MS Access中的SQL查询变量

MS Access中的SQL查询变量

在某种方式

parameters @test int;
select * from MyTable where ID = @test

但是,您不能使用set @test = 1234,在运行查询或在VBA中设置查询时可以手动输入参数。

您可以使用System.Data.OleDb命名空间中的类来查询访问数据库

Using cn As New OleDbConnection("connection string here"), _
      cmd As New OleDbCommand("SELECT query with ? parameter here", cn)

    cmd.Parameters.Add("?", OleDbType.Int).Value = 1234

    MyCombo@R_173_2419@.DataSource = cmd.ExecuteReader()
End Using

查询1

update MyTable2 set (...) where ID > (select max(test) from table1)

查询2

update MyTable3 set (...) where ID < (select max(test) from table1)
Access 2022/1/1 18:29:03 有312人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶