Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Need to get Excel data into an RDO recordset

Hello,

How can my VB6 application read an Excel table, in an already OPEN WORKBOOK, specifically into an RDO recordset? I must feed the RDO recordset to about a dozen VB6 classes that must be used AS IS.

Thanks,

Allan R. Kisner Sr.
Senior Analyst Programmer
Energizer Batteries/I.S. Dept.
[326 byte] By [vbasic321] at [2007-11-11 6:53:58]
# 1 Re: Need to get Excel data into an RDO recordset
Don't have anything on RDO, but perhaps you can adapt this ADO code?

Private Sub Command1_Click()
Dim cn As ADODB.connection
Dim rs As ADODB.Recordset
Dim sql As String
Dim connstr As String

connstr = "provider=microsoft.jet.oledb.4.0;data source=h:\TestExcelDB.xls;extended properties=Excel 8.0;"

Set cn = New ADODB.connection
cn.open connstr

sql = "select * from [Sheet1$]" 'specify where condition here
Set rs = New ADODB.Recordset

Set rs = cn.execute(sql)
rs.MoveFirst
While Not rs.EOF
Text1.Text = rs.Fields(0)
Text2.Text = rs.Fields(1)
Text3.Text = rs.Fields(2)
rs.MoveNext
Wend
End Sub
doofusboy at 2007-11-11 17:27:43 >
# 2 Re: Need to get Excel data into an RDO recordset
doofusboy,
Thank you for the response.

I'll probably try developing a connect string for RDO code similar to yours and see if I can get the table out of Excel.

If I'm unsuccessful, I'll probably adapt your ADO code to get the data then write a loop to transfer the values in the ADO recordset to an RDO recordset.

Again thanks.

vbasic321
vbasic321 at 2007-11-11 17:28:43 >