Private Sub Form_Load()
    Dim strConn As String
    Dim pubConn As New ADODB.Connection
    Dim rsTable As New ADODB.Recordset
    Dim strSQL As String    'Access 2000ªº³s±µ
    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\North.mdb;Persist Security Info=False"
    'SQL Server2000ªº³s±µ
    strConn = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=develop; password=12345;Data Source=ServerName"
    pubConn.Open strConn    rsTable.CursorLocation = adUseClient
    strSQL = "select  * from TableName"
    rsTable.Open strSQL, pubConn, adOpenDynamic, adLockOptimistic
    Set DataGrid1.DataSource = rsTableEnd Sub

解决方案 »

  1.   

    command查詢按鈕代碼    Dim strConn As String
        Dim pubConn As New ADODB.Connection
        Dim rsTable As New ADODB.Recordset
        Dim strSQL As String    'Access 2000
        strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\North.mdb;Persist Security Info=False"
        pubConn.Open strConn    rsTable.CursorLocation = adUseClient
        strSQL = "select  * from TableName where 名称='" & text1.text & "'"
        rsTable.Open strSQL, pubConn, adOpenDynamic, adLockOptimistic
        if not rsTable.eof then
            text2.text=rs!类型 & rs!地址
        else
            text2.text="沒有記錄"
        end if     rsTable.close
      

  2.   

    DataGrid1 是什么变量来的 ? 
      

  3.   

    DataGrid1 是什么变量来的 ? 这是个控件,不是个变量~~是用于显示你查询到的数据的控件,,,,,
      

  4.   

    菜单:
    工程——部件——microsoft datagird contorl6.0