很简单的,一个adodc1,一个datagrid,一个command,一个text.access中的数据字段id是自动编号的递增字段.我想实现当我在text1中输入一个数字(id数字),然后查询,就可以查询到这个id所对应的数据.可是,为什么总说"标准表达式中数据类型不匹配"
Adodc2.RecordSource = "select * from hcgz where id ='" & Text1.Text & "'"
Adodc2.CommandType = adCmdText
Adodc2.Refresh
DataGrid2.ReBind.
就是这样的,总说我"标准表达式中数据类型不匹配",那我要如何提出这组数据呢??

解决方案 »

  1.   

    数据库里的ID字段是字符串类型还是整数?
    Adodc2.RecordSource   =   "select   *   from   hcgz   where   id   ="   &   Text1.Text   
      

  2.   

    "select * from hcgz where id =" & Text1.Text & "" 
      

  3.   

    试试这个呢 "select   *   from   hcgz   where   id   ="   &   val(Text1.Text)
      

  4.   

    谢谢, 就是这样的:Adodc2.RecordSource = "select * from hcgz where id = " & Text9.Text & "",不用加那个单引号就可以了!!
      

  5.   

    Adodc2.RecordSource = "select *  from hcgz where  id  ="  &  val(trim(Text1.Text))
    trim:去掉文本框前后的空格。