🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Insert problem

#121
From: Tomislav Hundric'
Date: Sat, 15 Sep 2007 11:21
70 lines
3006 bytes
I'm sorry for asking before looking into help, I've managed to do it via 
  ADOCommand, but now I've got other question regarding my previous post 
about inserting excel file into Table.

Since I'm using:

INSERT INTO MyTable(Col1, Col2)
SELECT Col1, Col2
FROM [Sheet1$] IN ""[Excel 8.0;Database=c:\myxls.xls]

and that works fine when I enter it into SQL property of ADOQuery, but 
I'll be inserting lets say 10 or more excel files into table, I'm 
thinking of using loop that will add

...""[Excel 8.0;Database=c:\myxls1.xls]
...""[Excel 8.0;Database=c:\myxls2.xls]
...""[Excel 8.0;Database=c:\myxls3.xls]
...

since there are two quatation marks in front of the brackets, I don't 
know how to apply them to my string correctly.

String SQL = "INSERT INTO MyTable(Col1, Col2)SELECT Col1, Col2 FROM 
[Sheet1$] IN \"\"";

for (int i= 0; i < someNumber; i++){
	ADOCommand1->CommandText= SQL + "[Excel 8.0;Database=c:\myxls" + 
IntToStr(i) +".xls]";
	ADOCommand1->Execute();
}

or

for (int i= 0; i < someNumber; i++){
	ADOQuer1->SQL->Add(SQL + "[Excel 8.0;Database=c:\myxls" + IntToStr(i) 
+".xls]";
	ADOQuery1->ExecSQL();
}


Both of them throw me an exception "Microsoft Jet database engine could 
not find object Sheet1..." is there some other way to solve this.

Again, thanks in advance,
Tomislav.

Tomislav Hundric' wrote:
> Hi,
> I've got a question regarding insert into table, I'm using access 
> database, ADOConnection and ADOQuery:
> 
> 
> I have SQL like this:
> 
> Insert into Table1 (Field1)
> Select distinct Field2
>  From Table2
> 
> Executing this query throws me this error
> 
> "current provider does not not support returning multiple recordsets 
> from simple execution"
> 
> When I look into my table I can see that records are added even though 
> an error was thrown. Basically what I'm trying to do is to fill 
> relational tables with data from one temp table. Is my approach ok, or 
> should I do this in some other way.
> 
> Thanks in advance,
> Tomislav.
Technical Details
Message-ID: <46ebc074$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <46eba5b2@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,2042ce4cafe32ddf
X-Google-Attributes: gid10698b,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Sat, 15 Sep 2007 13:21:48 +0200
From: Tomislav Hundric' <rifnet@gmail.com>
User-Agent: Thunderbird 2.0.0.6 (Windows/20070728)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.database.ado
Subject: Re: Insert problem
References: <46eba5b2@newsgroups.borland.com>
In-Reply-To: <46eba5b2@newsgroups.borland.com>
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 83.131.43.115
Message-ID: <46ebc074$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1189855348 83.131.43.115 (15 Sep 2007 04:22:28 -0700)
Lines: 70
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail