1、一个Access数据库,如何设计一个查询,使它的参数等待输入,有两个参数,如人名和时间?
2、如何用VB输入这个查询的参数?
以前见过相关的帖子,但无论如何都找不到了,请高手指点!!!

解决方案 »

  1.   

    Dim rs As New ADODB.Recordsetrs.Open "select * from 人名 = '" & txtName.Text & "' and 时间 = #" & textTime.Text & "#"
      

  2.   

    rs.open "select * from table1 where 人名 = '" & txtName.Text & "' and 时间 = #" & textTime.Text & "#"支持狼狼~
      

  3.   

    支持:
    Dim rs As New ADODB.Recordsetrs.Open "select * from 人名 = '" & txtName.Text & "' and 时间 = #" & textTime.Text & "#"
      

  4.   

    不过,ACCESS数据库的查询语句支持参数定义.
      

  5.   

    输入查询的参数,你简单一点的话可以考虑用文本框,甚至Combox、listbox让用户选择!
      

  6.   

    加两个文本框,一个叫txtName存名字,一个txtTime存时间:
    然后Dim rs As New ADODB.Recordsetrs.Open "select * from 人名 = '" & txtName.Text & "' and 时间 = #" & txtTime.Text & "#"
      

  7.   

    rs.open "select * from 人名 = '" & txtName.Text & "' and 时间 = #" & txtTime.Text & "#"同意
      

  8.   

    对不起,我让大家理解错误了,我的意思是先在access中建立一个查询,但这个查询需要输入参数数据,然后从VB向其参数传输数据,没有人这么作过吗?
      

  9.   

    如果是SQL的话就可以用存储过程了,Access是不支持这样的。考虑一下SQL的存储过程吧。然后用下面的语句调用:
    dim myconn as new adodb.connection
    dim myrs as new adodb.recordset
    myconn.connectionstring=yourconnstring
    querystring="Exec myproc '" & txtname.text & "','" & txttime.text & "'"
    set myrs=mydb.execute(querystring)
    这样就可以实现你的代参数查询的要求了。而且执行效率高了许多。
      

  10.   

    对于这样一个查询 Select * From 表名 Where 字段名=变量名 的参查询
    在vb中可以使用Adodb.command 和 adodb.P**** 两个对象进行.在msdn中有
    详细的解决示例。具体的代码可参照示例.
      

  11.   

    access中的VBA功能比较弱,完成不了这样的操作。
      

  12.   

    Dim rs As New ADODB.Recordsetrs.open"SELECT * FROM 表名 WHERE 人名='"+trim(txtRm)+"'" 
    and 时间='"+trim(txtSj)+"'......  即可!
      

  13.   

    用" & 变量名 & "引用变量,如果是字符型,请在前后加'(单引号),
      

  14.   

    dim AdoCx as adodb.recordset 
    set adocx=new adodb.recordset
    adocx.open" select * from 表名 where 姓名 like '"+trim(text.text)+"%' and 
    format(时间,"yyyy-mmm-dd")='"+format(trim(时间控件),yyyy-mm-dd)+"'.............