How to connect with excel file using ADO
Please provide the code to connect with excel file using ado.
i want to use it as database.
so please provide the code.
thanks
ravi
[152 byte] By [
ravisingh] at [2007-11-15 16:17:27]

# 1 Re: How to connect with excel file using ADO
' this will connect to an excel file
Dim cn as ADODB.Connection
set cn = new ADODB.Connection
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=C:\MyFolder\MyWorkbook.xls;" & _
"Extended Properties=Excel 8.0;"
.Open
End With
' this will select data from it
dim rs as ADODB.Recordset
' to select the entire sheet
strQuery = "SELECT * FROM [Sheet1]"
' or to select just a portion of it
strQuery = "SELECT * FROM [Sheet1$A1:B10]"
set rs = cnn.execute(strQuery)
Tom Cannaerts
slisse@planetinternet.be
Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
Cakkie at 2007-11-10 0:59:01 >

# 2 Re: How to connect with excel file using ADO
Hi!
This is just what I need. But I have a problem that is rather frustrating. I cant get any rows from the Excel file. I can see what fields are in the sheet but no records.
Any suggestions???
# 3 Re: How to connect with excel file using ADO
Since ADO is not included in VB6.0 Learning Edition and I don't want to just go out and get an upgrade right now is there some way I can use my VC5.0 Prof and OLE DB to create something similar enough to use as the ADODB class and/or object for my VB ADO ventures?
# 4 Re: How to connect with excel file using ADO
Why not just download the MDAC SDK (Microsoft Data Access Components Software Development Kit). It's free for download at msdn.microsoft.com, includes a lot of samples, everything you need to get started.
Tom Cannaerts
slisse@planetinternet.be
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
Cakkie at 2007-11-10 1:02:07 >
