我想用表的形式保存程序中生成的记录集,并将它放在事先建的数据库里,请问如何用程序来实现?
事先建的数据库:d:/db.mdb
程序中生成的记录集:rstx

解决方案 »

  1.   

    Option ExplicitPublic rs As New ADODB.Recordset
    Public conn As New ADODB.Connection
    Private Sub Form_Load()
     Dim strconn As String
     strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\test.mdb;Persist Security Info=False"
     conn.CursorLocation = adUseClient
     
     conn.Open strconn
     
     If rs.State = 1 Then rs.Close
     rs.Open "Select * from People", conn, adOpenKeyset, adLockPessimistic
     
     Set Me.DataGrid1.DataSource = rs
     End Sub/////
    你告訴我 rs.Open "Select * from People", conn, adOpenKeyset, adLockPessimistic
    以後你想幹什麼?到底是從表中取還是插入表中
    ,插入你就用上面那句以後,addnew你所有記錄就可以了
      

  2.   

    程序中生成的记录集:rstx是怎么生成的?
    如果也是用SQL语句生成,那么可以加INto关键词解决问题,如:yourTable="rstx"
    SqlStr="Select * into " & yourTable & " from yourSourceTable Where yourCondition"
    set rstx=conn.Execute(SqlStr)则在查到记录集的同时保存了你的表
    更改了数据后用rstx.Update更新数据表就行了。