对 MS Access 2003 执行动态 SQL 查询 [英] Execute a dynamic SQL Query against MS Access 2003

查看:50
本文介绍了对 MS Access 2003 执行动态 SQL 查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个超级基本问题,但我正在尝试执行一个查询,该查询是通过针对表单所在的 MS Access 数据库的一些表单值构建的.我不认为我需要正式通过 ADO,但也许我会.

This is a super basic question but I'm trying to execute a Query that I'm building via some form values against the MS Access database the form resides in. I don't think I need to go through ADO formally, but maybe I do.

无论如何,将不胜感激.很抱歉成为n00b.;)

Anyway, some help would be appreciated. Sorry for being a n00b. ;)

推荐答案

您可以使用以下 DAO 代码来查询 Access DB:

You can use the following DAO code to query an Access DB:

Dim rs As DAO.Recordset
Dim db As Database

Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM Attendance WHERE ClassID = " & ClassID)

do while not rs.EOF
  'do stuff
  rs.movenext
loop

rs.Close
Set rs = Nothing

就我而言,ClassID 是表单上的文本框.

In my case, ClassID is a textbox on the form.

这篇关于对 MS Access 2003 执行动态 SQL 查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆