ADO控件开发数据库(ACCESS),查找代码
Private Sub Command3_Click()
Dim str As String
Dim mybook As Variant
mybook = Adodc1.Recordset.Book
str = InputBox("输入查找表达式", "查找")
If str = "" Then Exit Sub
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find str
If Adodc1.Recordset.EOF Then
MsgBox "没有此项", , "信息提示"
Adodc1.Recordset.Book = mybook
End If
End Sub
查找数据库里的数字可以,汉字不能查找,为什么?

解决方案 »

  1.   

    dim con as connection
    dim adoprimaryrs as adodb.recordsetset con=new adodb.connection
        con.open "连接的字串"
    set adoprimaryrs=new adodb.recordset 
        adoprimaryrs.open 查询语句
      

  2.   

    最好别用ADODC控件,查找
    最好用SQL语句,
    例如:
    Dim ado_conn as new adodb.connection
    Dim ado_recnewsell As New ADODB.Recordset
    Dim str_sqlnewsell As Stringado_conn.connectionstring = "..........." '连接字符串
    ado_conn.openstr_sqlnewsell = "SELECT selldate,sellmoney " & _
                     "FROM t_newsell " & _
                     "WHERE (selldate between '" & dtp_toptime & "' AND '" & dtp_endtime & "') And (lvbm =" & "'" & m_bmlsdid & "') " & _
                     "ORDER BY selldate"
                         
        ado_recnewsell.CursorLocation = adUseClient
        ado_rec.Open Trim$(SQL), ado_conn, adOpenDynamic, adLockOptimistic其中dtp_toptime,dtp_endtime,m_bmlsdid 为自定义的变量,希望能给你一些参考和提示
      

  3.   

    我是ADODC控件和DBGRID控件绑定,哪位高手知道啊