在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如何实现呢???请高手指教!!!!
我查询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如何实现呢???请高手指教!!!!
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
agree with this one
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