I'm trying to insert records from an ADO recordset created from a delimited text file into another recordset connected to a physical database. I'm working in VB6, ADO 2.5 and (for now) an Access database. This code:
Set cn = New ADODB.Connection
Set rsWorkFile = New ADODB.Recordset
Set db = New ADODB.Connection
Set rsReturns = New ADODB.Recordset
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\;Extended Properties='text; HDR=NO;FMT=Delimited'"
db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Test_Returns.mdb;Persist Security Info=False"
rsWorkFile.Open "SELECT * FROM [WorkFile.txt]", cn, adOpenKeyset, adLockReadOnly
db.Execute "INSERT INTO returns SELECT * FROM " & rsWorkFile & ""
gives me a Type mismatch compile error. If I change the db.Execute line to:
db.Execute "INSERT INTO returns SELECT * FROM rsWorkFile"
I get an error that says the Jet engine can't find the table or query rsWorkFile.
What am I missing here?
Set cn = New ADODB.Connection
Set rsWorkFile = New ADODB.Recordset
Set db = New ADODB.Connection
Set rsReturns = New ADODB.Recordset
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\;Extended Properties='text; HDR=NO;FMT=Delimited'"
db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Test_Returns.mdb;Persist Security Info=False"
rsWorkFile.Open "SELECT * FROM [WorkFile.txt]", cn, adOpenKeyset, adLockReadOnly
db.Execute "INSERT INTO returns SELECT * FROM " & rsWorkFile & ""
gives me a Type mismatch compile error. If I change the db.Execute line to:
db.Execute "INSERT INTO returns SELECT * FROM rsWorkFile"
I get an error that says the Jet engine can't find the table or query rsWorkFile.
What am I missing here?