如题
请给代码,谢谢
还有怎么实现模糊查询呀?

解决方案 »

  1.   

    1、绑定
    2、自己逐条加载
        Dim Rs As New ADODB.Recordset    Dim strSql As String
        Dim blnIni As Boolean
        Dim LstItem As ListItem
        
        On Error GoTo ErrHandle
        
        strSql = "SELECT [ChapId], [NodeId], [ByeLowId], [Description], " & _
            "[LowMoney] , [HighMoney], [Bid],[NormalMoney] " & _
            "FROM [test].[dbo].[ByeLow] "            
        Set Rs = New ADODB.Recordset
        Rs.Open strSql, Cn, adOpenStatic, adLockReadOnly
        
        With LstByeLow
        
            .ListItems.Clear
            While Not Rs.EOF
                Set LstItem = .ListItems.Add(, "B" & Rs.Fields("Bid"), Rs.Fields("Chapid") & "")
               
                LstItem.SubItems(1) = Rs.Fields("Nodeid") & ""
                LstItem.SubItems(2) = Rs.Fields("Description") & ""
                LstItem.SubItems(3) = Rs.Fields("LowMoney") & ""
                LstItem.SubItems(4) = Rs.Fields("HighMoney") & ""
                LstItem.SubItems(5) = Rs.Fields("NormalMoney") & ""
                
                Rs.MoveNext
            Wend
            
        End With
            Rs.Close
        Set Rs = Nothing
        LoadByeLow = True
        Exit Function
        
    ErrHandle:
      

  2.   

    Private Sub DataToList()
    On Error GoTo mErr
        Dim mRst As New ADODB.Recordset
        Dim mLItem As ListItem
        lsvLesnIfm.ListItems.Clear
        mRst.CursorLocation = adUseClient
        mRst.Open "SELECT * FROM tblLesson ORDER BY 课程号", mCnnString, adOpenStatic, adLockOptimistic, adCmdText
        Do Until mRst.EOF
            Set mLItem = lsvLesnIfm.ListItems.Add(, , mRst("课程号"))
            With mLItem
                .SubItems(1) = mRst("课程名称")
                .SubItems(2) = mRst("教材名称")
                .SubItems(3) = mRst("任课老师")
                .Tag = mRst("课程ID")
            End With
            mRst.MoveNext
        Loop
        mRst.Close
        Set mRst = Nothing
        Exit Sub
    mErr:
        MsgBox Err.Number & "," & Err.Description, vbCritical + vbOKOnly, mTitle
        End
    End Sub
      

  3.   

    Do While Not rs.EOF
                Set rs2 = New ADODB.Recordset
                sql2 = "Select * From zjj_hbzldzb Where GS_HBZLID='" & rs("zczbbm") & "'"
                rs2.Open sql2, cnn, 1
                
               Set Item = lvwdm.ListItems.Add()
                Item.Text = Trim(rs("qybs"))
                Item.SubItems(1) = Trim(rs("zch"))
                If Not IsNull(rs("qymc")) Then Item.SubItems(2) = Trim(rs("qymc"))
                If Not IsNull(rs("zs")) Then Item.SubItems(3) = Trim(rs("zs"))
                If Not IsNull(rs("fddbr")) Then Item.SubItems(4) = Trim(rs("fddbr"))
                If Not IsNull(rs("fddbrsfzh")) Then Item.SubItems(5) = Mid(Trim(rs("fddbrsfzh")), 2, Len(Trim(rs("fddbrsfzh"))) - 1)
                If Not IsNull(rs("jyfw")) Then Item.SubItems(6) = Trim(rs("jyfw"))
                If Not IsNull(rs("dh")) Then Item.SubItems(7) = Trim(rs("dh"))
                If Not IsNull(rs("qyzczb")) Then Item.SubItems(8) = Trim(rs("qyzczb"))
                If Not rs2.EOF Then Item.SubItems(9) = Trim(rs2("ZJ_HBZLID"))
                If Not rs2.EOF Then Item.SubItems(10) = Trim(rs2("GS_HBZLMC"))
            rs.MoveNext
            rs2.Close
    Loop
    rs.Close
    lvwdm.SelectedItem = Nothing
      

  4.   

    模糊查询,使用SQL的sql关键字