haha,no points no answer?on Click event of commandbutton, show the dialog, then get the path of the database file. and create a connection to the database and create a recordset point to the table.
In the end, set datasoure and datamember of the grid.

解决方案 »

  1.   

    '*************************
    'Just Try It.........   
    'use Commondialog,msflexgrid
    'code:
    '************************dim dbasename as string 
    dim sql_str as string 
    dim conn as adodb.connectiong
    dim Redset as adodb.recordset    Commondialog.InitDir = "f:\"
        Commondialog.Filter = "Access(*.mdb)|*.mdb"
        Commondialog.DefaultExt = "Access(*.mdb)|*.mdb"
        Commondialog.filename = ""
        Commondialog.CancelError = False
        Commondialog.ShowSave
        
        If Commondialog.filename <> "" Then
           
           dbasename=Commondialog.filename '''get databasename
           sql_str="select leibie,dingjia  from product"       conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="  & dbasename & ";Persist Security Info=False"    Redset.CursorLocation = adUseClient
        Redset.CursorType = adOpenStatic
        Redset.Open sql_str, conn, adOpenDynamic, adLockOptimistic
        set msflexgrid.datasource=Redset
    end if'*************************
    'Just Try It.........   
    '************************
      

  2.   

    谢谢: mousean(幻想无限) ,nebular(星云) ( )