Article View: borland.public.cppbuilder.database.ado
Article #6Re: ADOConnection, ADOTable, ADOQuery Basics
From: Clayton Arends
Date: Thu, 21 Feb 2008 20:41
Date: Thu, 21 Feb 2008 20:41
42 lines
2677 bytes
2677 bytes
"Sudesh" <sudeshc@vfemail.net> wrote in message
news:47bdbf12@newsgroups.borland.com...
> I could not get one thing working. Could you please tell me what's wrong
> below:
>
> ADOQuery1->SQL->Clear();
> ADOQuery1->Close();
Personally, I'd put the close before the clear. Also note, when you clear
SQL TADOQuery will implicitly close the database. I'd still leave the call
to close in there to make it obvious what you are doing.
> ADOQuery1->SQL->Add("SELECT * FROM marks ");
> ADOQuery1->SQL->Add("WHERE student_score > 25");
> ShowMessage(ADOQuery1->SQL->Text);
> ADOQuery1->Open();
Looks fine.
> //ADOQuery1->ExecSQL();
> ADOQuery1->Active = false;
Remove these two lines.
> With this code, I still see all the records in DBGrid instead of records
> having score >25.
I assume the grid's DataSource property references a datasource on your form
(ie. DataSource1). The datasource's DataSet property should be linked to
ADOQuery1. If that's how things are configured then you should only be
seeing records with student_score > 25. If you can't get this to work then
in the IDE switch to your form's designer view. Type ALT+F12 to switch to
edit the DFM of the form. Select all, copy, and paste this in your response
to my post.
> is ExecSQL() required or Open() and Active is ok?
ExecSQL() is used to execute commands that return no data like INSERT,
UPDATE, and DELETE. Use Open() or "Active = true" to open a SELECT command.
Clayton
Technical Details
Message-ID:
<47bde202$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.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-mailReferences:
<47b97333@newsgroups.borland.com> <47bda663$1@newsgroups.borland.com> <47bdbf12@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10698b,a49b6386b1d150d4 X-Google-Attributes: gid10698b,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Clayton Arends" <nospam_claytonarends@hotmail.com> Newsgroups: borland.public.cppbuilder.database.ado References: <47b97333@newsgroups.borland.com> <47bda663$1@newsgroups.borland.com> <47bdbf12@newsgroups.borland.com> In-Reply-To: <47bdbf12@newsgroups.borland.com> Subject: Re: ADOConnection, ADOTable, ADOQuery Basics Date: Thu, 21 Feb 2008 12:41:28 -0800 Lines: 43 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Windows Mail 6.0.6000.16480 X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6000.16545 NNTP-Posting-Host: 68.185.45.89 Message-ID: <47bde202$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1203626498 68.185.45.89 (21 Feb 2008 12:41:38 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.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