form2.adodc1.RecordSource="select * from DBStudent "_
          &"where 姓名=' " & Form1.Adodc1.Recordset.Fields("姓名") & " '  "
form2.adodc1.refresh出现执行错误:
Method 'refresh' of object 'IAdodc' failed请问这是为什么呢
是不是where语句出现了错误?该怎么写where语句呢?

解决方案 »

  1.   

    晕菜,你初级学习数据库?居然用2个adodc控件?你换成ado好了很简单,因为你连接adodc1生成的Adodc1.Recordset.Fields("姓名")  是有很多条数据,而且不能刷新adodc1不是SQL语句问题,是你应用本身的错误学习用ADO连接,一个数据库只有一个Connection就足够
      

  2.   

    form2.adodc1.RecordSource="select * from DBStudent "_
              &"where 姓名=' " & Form1.Adodc1.Recordset.Fields("姓名") & " '  "
    form2.adodc1.refresh你在这个地方逻辑出了问题Form1.Adodc1.Recordset.Fields("姓名") & " ' 这个是个数据集合,就是说是Form1.Adodc1通过查询选出来的数据集和,里面可能有张三,李四,王二麻子....select * from DBStudent "_
              &"where 姓名=' " & Form1.Adodc1.Recordset.Fields("姓名") & " ' 这个sql放在这里就不成立了
    如果是这样
    select * from DBStudent "_
              &"where 姓名='张三' or 姓名='李四' "
    这样就好了具体怎么改,还要根据需要。 
      

  3.   

    Form1.Adodc1.Recordset.Fields("姓名")
    的作用是在form1中选择一个姓名,然后在form2中显示对应于该姓名的记录这个是逻辑问题吗,我觉得逻辑上好象没有错误,不知道错在哪儿,请高手指教,谢谢
      

  4.   

    那你试验一下用一个绝对的值代替Form1.Adodc1.Recordset.Fields("姓名") 看看能不能刷新
      

  5.   

    用一个绝对的值代替Form1.Adodc1.Recordset.Fields("姓名") 也不能刷新,这是为什么呢?
      

  6.   

    form2.adodc1.RecordSource="select * from DBStudent "_
              &"where 姓名=' " & Form1.txtName.Value & " '  "
    在form1得文本框中输入姓名却是可以刷新得,这是为什么呢
      

  7.   

    form2.adodc1.RecordSource="select * from DBStudent "_
              &"where 姓名=' " & Form1.txtName.Text & " '  "
                                               ~~~~~刚刚打错了
    在form1得文本框中输入姓名却是可以刷新得,这是为什么呢
      

  8.   

    要在form2显示 form1.txtName的相关记录Do Until Adodc1.Recordset.EOF
       Adodc2.RecordSource = "select * from  DBStudent where 姓名= '" & form1.Adodc1.Recordset.Fields.Item("姓名").Value & "' "   Adodc1.Recordset.MoveNext
    Loop基本上应该是这样了
    但这样的效率不高
    楼主自己想办法吧
      

  9.   

    刚才我写的有一点点错误
    就是你在Adodc1前要+上 form1
      

  10.   

    form2.adodc1.RecordSource="select * from DBStudent "_
              &"where 姓名=' " & Form1.txtName.Value & " '  "
    form2.adodc1.RecordSource="select * from DBStudent "_
              &"where 姓名=' " & Form1.Adodc1.Recordset.Fields("姓名") & " '  "这两个的语法是一样的,为什么上面的可以执行,下面的却出错呢?
      

  11.   

    form2.adodc1.RecordSource="select * from DBStudent "_
              &"where 姓名=' " & Form1.Adodc1.Recordset.Fields("姓名") & " '  "
    form2.adodc1.refresh标准表达式中数据执行错误
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~这句话是什么意思呢??
    出现执行错误:
    Method 'refresh' of object 'IAdodc' failed