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

解决方案 »

  1.   

    form2.adodc1.RecordSource="select * from DBStudent "_
              &" where 姓名=' " & Form1.Adodc1.Recordset.Fields("姓名") & " '  "WHERE前面加一空格试一下
      

  2.   

    form2.adodc1.RecordSource="select * from DBStudent" & _
                     "where 姓名='" & Form1.Adodc1.Recordset.Fields("姓名") & "'"如果要换行应该在&和_之间加一个空格,按照这样写写!
      

  3.   

    首先检查form2的adodc1的CommandType 属性是否为adCmdText或adCmdUnknown
    如果是,那么把sql语句打印到立即窗口,检查sql语句是否正确form2.adodc1.RecordSource="select * from DBStudent "_
              &"where 姓名=' " & Form1.Adodc1.Recordset.Fields("姓名") & " '  "
    Debug.Print form2.adodc1.RecordSource   '<------------------在立即窗口查看sql语句是否正确
    form2.adodc1.refresh