Article View: borland.public.cppbuilder.database.ado
Article #1259Re: SELECT after UPDATE
From: Viatcheslav V. Vassiliev
Date: Tue, 07 Sep 2004 11:50
Date: Tue, 07 Sep 2004 11:50
144 lines
5375 bytes
5375 bytes
Try to use TADOConnection component - the same for both queries. MS Jet uses
"lazy writes" and changes become visible to other users (other programs,
other connections) after 5 seconds.
SystemQuery->Connection = ADOConnection1;
instead of
SystemQuery->ConnectionString = "...";
//------------------------------------------
Regards,
Vassiliev V. V.
http://www.managed-vcl.com - using .Net objects in Delphi for Win32 +
ADO.Net
http://www.oledbdirect.com - The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)
"Drew" <aemsley@brightwell.org.uk> �������/�������� � �������� ���������:
news:413d754c@newsgroups.borland.com...
> I'm using BCB6 Professional, MS Access 2000 and MS Jet 4.0.
>
> If I do an UPDATE on a able, followed immediately afterwards by a SELECT
on
> the same fields in the same table, the values returned by the SELECT do
not
> show the values that were updated by the UPDATE command.
>
> However, if I step through the code in the debugger or explicitly wait for
a
> period, then the new values are returned by the SELECT.
>
> I thought that ADO immediately wrote the new values to the table, or do I
> have to wait for the ExecSQL command to complete?
>
> The code in question is below:
>
>
//--------------------------------------------------------------------------
> ---------------------------------------
> void __fastcall WbSvrThread::WebServerUpdateSystemParameters(TIdCommand*
> ASender)
> {
> TADOQuery* SystemQuery;
>
> try
> {
> SystemQuery = new TADOQuery(NULL);
> SystemQuery->ConnectionString =
> "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Program Files\\Hilltop
> Monitoring System\\hilltop.mdb;Mode=ReadWrite|Share Deny None;Persist
> Security Info=False";
>
> sysParams_t replyBuffer;
> AnsiString sqlString;
>
> sqlString.sprintf("UPDATE SystemTable SET
IPConnectRetriesNormal=%s,
> IPConnectRetriesFailed=%s, IPConnectTimeout=%s, TelRetriesNormal=%s,
> TelRetriesFailed=%s, TelTimeout=%s, NormalScheduleFrequency=%s,
> AlarmScheduleFrequency=%s, RtrFrequency=%s",
> ASender->Params->Strings[0],
> ASender->Params->Strings[1], ASender->Params->Strings[2],
> ASender->Params->Strings[3],
> ASender->Params->Strings[4], ASender->Params->Strings[5],
> ASender->Params->Strings[6],
> ASender->Params->Strings[7], ASender->Params->Strings[8]);
> SystemQuery->SQL->Clear();
> SystemQuery->SQL->Add(sqlString);
> SystemQuery->Prepared = true;
>
> AnsiString msgType;
>
> try
> {
> SystemQuery->ExecSQL();
>
> msgType=ACK;
>
> // Send the confirmation to the webserver
> ASender->Thread->Connection->WriteLn(msgType);
>
> ParentForm->FindScanIntervals();
> }
> catch (Exception &e)
> {
> sprintf(msg, "Updating system parameters in database failed:
> exception = %s", e.Message);
> Log(0, msg);
>
> msgType=NACK;
>
> // Send the negative confirmation to the webserver
> ASender->Thread->Connection->WriteLn(msgType);
> }
> }
> catch(Exception &e)
> {
> sprintf(msg, "WebServerUpdateSystemParams failed: exception = %s",
> e.Message);
> Log(0, msg);
> }
> delete SystemQuery;
> }
>
>
> void __fastcall TForm1::FindScanIntervals(void)
> {
> AnsiString sqlString;
>
> sqlString.sprintf("SELECT NormalScheduleFrequency,
> AlarmScheduleFrequency, RtrFrequency FROM SystemTable");
> ADOQuery1->SQL->Clear();
> ADOQuery1->SQL->Add(sqlString);
>
> try
> {
> ADOQuery1->Open();
>
> if (ADOQuery1->RecordCount > 0)
> {
> NormalScanSchedule =
> ADOQuery1->Fields->FieldByNumber(1)->AsInteger * 60;
> AlarmScanSchedule =
> ADOQuery1->Fields->FieldByNumber(2)->AsInteger * 60;
> RouterFrequency =
ADOQuery1->Fields->FieldByNumber(3)->AsInteger
> * 60;
> }
>
> ADOQuery1->Close();
>
> }
> catch(...)
> {
> Log("SQL Update failed");
> }
>
> }
>
>
> Any ideas/suggestions gratefully received.
>
> Andrew
>
>
Technical Details
Message-ID:
<413da095$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!news.moat.net!news.linkpendium.com!news.linkpendium.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<413d754c@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,2974e2a27d708c67 X-Google-Attributes: gid10698b,public X-Google-Language: ENGLISH,ASCII From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com> Newsgroups: borland.public.cppbuilder.database.ado References: <413d754c@newsgroups.borland.com> Subject: Re: SELECT after UPDATE Date: Tue, 7 Sep 2004 15:50:46 +0400 Lines: 146 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: 213.234.218.42 Message-ID: <413da095$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1094557845 213.234.218.42 (7 Sep 2004 04:50:45 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!news.moat.net!news.linkpendium.com!news.linkpendium.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail