🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #750

Re: How to Access Excel File by ADOQuery

#750
From: Yifei
Date: Mon, 04 Apr 2005 06:02
50 lines
2343 bytes
First,you must set the ConnectionString of the TADOConnection like that:
Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=D:\DevWorkshop\NHTAbrasives\Dataimport\�ĵ�ģ��.xls;Extended
Properties=Excel 8.0;Persist Security Info=False
notice:the "Source" section you must set the path of you .xls file.
Second,you can put a TADOTable on the TForm,then Set the Connection
properties to the ADOConnection you had set the ConnectionString,
the set the TableDirect Properties  to true,
select the TableName for $sheet1,
then you can read and write the Excel file,
but you can't delete from it,becase it's a linked table.

"FlyR" <john.wild@msa.hinet.net> д���ʼ�
news:416b493e@newsgroups.borland.com...
> my ADOQuery Control set as follow.
>
>   object Query: TADOQuery
>     ConnectionString =
>       'Provider=MSDASQL.1;Persist Security Info=False;Data Source=Data
>     Parameters = <>
>     Left = 48
>     Top = 40
>   end
>
>
>
>
> void __fastcall TForm1::Button1Click(TObject *Sender)
> {
> AnsiString SqlStr;
>
> SqlStr="Select * from ImageDataBase";
> Query->SQL->Clear();
> Query->SQL->Add(SqlStr);
> Query->Open();
>
> Query->Append();
> Query->FieldValues[0] ="test";
> Query->Post();
> }
>
> then I add a ODBC data source for Excel file. The Data Soruce name is
> "Data".
>
>
> I Excute this program. It has something wrong. But I cant solve it. Please
> help me.
> Thanx.
>
>
Technical Details
Message-ID: <4250d86b@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <416b493e@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,417b4be6798e6a92
X-Google-Attributes: gid10698b,public
X-Google-Language: ENGLISH,ASCII
From: "Yifei" <yinjiajun@gmail.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <416b493e@newsgroups.borland.com>
Subject: Re: How to Access Excel File by ADOQuery
Date: Mon, 4 Apr 2005 14:02:31 +0800
Lines: 52
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
NNTP-Posting-Host: 211.162.16.109
Message-ID: <4250d86b@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1112594539 211.162.16.109 (3 Apr 2005 23:02:19 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail