Reading XLS file

From: Doug Szper (dszper_at_earthlink.net)
Date: 11/24/04


Date: Tue, 23 Nov 2004 17:14:07 -0600

I am new to ADO. I have created a form with a TADOConnection "dsConnect" (to
the XLS file), and a TADODataSet "dsUsers" (to the specific *** of the XLS
file). I also have put a TDBGrid and TDataSource "dsSource" on the form. The
dsSource.DataSet := dsUsers.

I have no idea what to do next. I would like to populate the DBGrid with data
from the XLS file.

I tried calling
dsUsers.GetFieldNames (dsStrings);
but I get 42 strings "F1", "F2", ..."F42". They have no special meaning for
this file.

Ultimate goal is to read, modify and update the spread***. I assume that
populating a TDBGrid is the best way, but am open to alternatives. For a
start, I just want to read something from the file. Any help will be
appreciated.

Second Problem:

Also, when I use the tADOConnection, and link the TADODataSet to it,
(dsUsers.Connection := dsConnect), I get an error "Read only property was not
set" when I call dsUsers.Open. When I set the ConnectionString in the
TADODataSet directly, this goes away. I guess this is happening on
dsConnect.Open. When I break the connection and do dsUsers.Open, it works.
Well, it doesn't give an error message, anyway.

Connection String:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\t$\sedb.xls;Extended
Properties=excel 8.0;Persist Security Info=False

Is there more I have to put into the dsConnect.ConnectionString for the
dsConnect?

Thanks,
Doug Szper


Quantcast