🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Multiple INSERT INTO statements

#2765
From: Blazek Jaroslav
Date: Wed, 02 Apr 2003 12:54
66 lines
2387 bytes
Hi,

/*------------- ADOQueryEx.h ----------------*/
class PACKAGE TADOQueryEx : public TADOQuery
{
public:
        void __fastcall BeginFastAdd();
        void __fastcall EndFastAdd();
};

/*------------- ADOQueryEx.cpp --------------*/

void __fastcall TADOQueryEx::BeginFastAdd()
{
 if (!ComponentState.Contains(csLoading))
   Close();
 (dynamic_cast<TStringList *>(SQL))->OnChange = NULL;
}

void __fastcall TADOQueryEx::EndFastAdd()
{
 (dynamic_cast<TStringList *>(SQL))->OnChange = QueryChanged;
 QueryChanged(SQL);
}

/*------------- example ------------*/
 ADOQueryEx->BeginFastAdd();
 try
  {
   ADOQueryEx->SQL->Clear();
   for (int i = 0; i < 1000; i++)
    ADOQueryEx->SQL->Add("INSERT MyTable (ColText) VALUES ('value')");
  }
 __finally
  {
   ADOQueryEx->EndFastAdd();
  }
  
 try
  {
   ADOQueryEx->ExecSQL();
  }
 catch(...)
  {
   ShowMessage("Error");
  }

Bc. Jaroslav Blazek
Access-IT Ceska Lipa
Jaroslav.Blazek@access-it.cz
http://www.access-it.cz

"Jonny" <jonny@nospam.jonnywilk.co.uk> wrote in message news:<b5vimu$ruo$1$8302bc10@news.demon.co.uk>...
> Hi
> 
> I've got an application that needs to insert serval values into a table say
> between 100-1000 rows.  At the moment i've got an ADO connection to the
> database, and then using an ADO Query i've got an INSERT INTO statement
> that's placed in a for loop adding each row.
> 
> This, however, is REALLY slow!  What's the best way do this quickly
> 
> Thanks
> 
> 
> Jonny
Technical Details
Message-ID: <159ea77c.0304020454.41782a3@posting.google.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail
References: <b5vimu$ruo$1$8302bc10@news.demon.co.uk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,4d999a3943779361
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2003-04-02 04:54:36 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail
From: Jaroslav.Blazek@access-it.cz (Blazek Jaroslav)
Newsgroups: borland.public.cppbuilder.database.ado
Subject: Re: Multiple INSERT INTO statements
Date: 2 Apr 2003 04:54:35 -0800
Organization: http://groups.google.com/
Lines: 66
Message-ID: <159ea77c.0304020454.41782a3@posting.google.com>
References: <b5vimu$ruo$1$8302bc10@news.demon.co.uk>
NNTP-Posting-Host: 213.180.32.14
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1049288076 1536 127.0.0.1 (2 Apr 2003 12:54:36 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 2 Apr 2003 12:54:36 GMT