在VB中如何将SQL查询出来的结果输出到已经存在的ACCESS表中d:\aaa.mdb的111表中
我查询SQL的语句如下:
Dim con     As ADODB.Connection
Set con = New ADODB.Connection
Dim rs4      As ADODB.RecordsetSet rs4 = New ADODB.Recordset
xlsPointer = 2con.CommandTimeout = 0
con.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID= sa;password=sa;Initial Catalog=uep;Data Source=127.0.0.1"
yhzlcx_str = "select neId, count(*)*32 from cardstatistic where CardType='USR_PSTN' group by neId"rs4.CursorLocation = adUseClient
rs4.CursorType = adOpenStatic
rs4.LockType = adLockPessimistic
rs4.Open yhzlcx_str, con, adOpenDynamic, adLockOptimisticIf (rs4.RecordCount = 0) Then
MsgBox "数据库中无此记录!"
Else??????????????'输出到d:\aaa.mdb中的111表中,列数和原来一样!!END IF
End Sub如何实现呢???请高手指教!!!!

解决方案 »

  1.   

    If (rs4.RecordCount = 0) Then 
        MsgBox "数据库中无此记录!" 
    Else 
        dim ac_Tmp    as new adodb.connection
        With ac_Tmp
            If .State = adStateOpen Then .Close
            .ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\aaa.mdb;Mode=ReadWrite;Persist Security Info=False"
            .Open
        End With
        ac_Tmp.execute " insert into [111](newid,aa) values('"& rs4(0) &"',"& rs4(1) &")"
        ac_tmp.close
    END IF 
    End Sub 
      

  2.   


    agree with this one
      

  3.   

    ac_Tmp.execute " insert into 表名(字符型字段,数值型字段) values('"& 字符型变量 &"',"& 数值型变量 &")"
      

  4.   

    access数据库中表名、字段名与字段类型分别是什么?
      

  5.   

    If (rs4.RecordCount = 0) Then 
        MsgBox "数据库中无此记录!" 
    Else 
        dim i as long
        dim ac_Tmp    as new adodb.connection
        With ac_Tmp
            If .State = adStateOpen Then .Close
            .ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\aaa.mdb;Mode=ReadWrite;Persist Security Info=False"
            .Open
        End With
        for i=1 to rs4.recordcount
            ac_Tmp.execute " insert into [111](newid,aa) values('"& rs4(0) &"',"& rs4(1) &")"
            rs4.movenext
        next i
        ac_tmp.close
    END IF 
    End Sub