我的工程文件放在c:\vb中,里面也有个student.mdb;请教我吧;

解决方案 »

  1.   

    Dim rs As New ADODB.Recordset
    Dim conn As New ADODB.Connection
    Dim strSql As String
    Dim strSeach As StringstrSql = App.Path & "\student.mdb"
    strSql = Replace(strSql, "\\", "\")strSeach="select * from 成绩"   '可以用你自己的SQL语句替换With conn       '连接字段及使用方式
           If .State = adStateOpen Then
              .Close
           End If
           .CursorLocation = adUseClient
           .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & strSql
           .Open
       End With
       
    With rs
           .Open  strSeach, conn, 3, 3  '可以用你自己的SQL语句替换
           If .BOF And .EOF Then
              MsgBox "没有任何记录", , "提示"
            Exit Sub
           End If
           .MoveFirst
           .MoveLast
    End WithSet DataGrid1.DataSource = rs'将结果返回你的DataGrid1控件并显示
    DataGrid1.Refresh
      

  2.   

    请参考
    http://expert.csdn.net/Expert/topic/2710/2710006.xml?temp=8.526248E-02