Board index » delphi » How to post an update to ADO dataset with where condition.

How to post an update to ADO dataset with where condition.

I have an ADO dataset and want to update a field with the post method.
With a SQL statement I would 'UPDATE MDCOUT SET DRIVER =  'JOHN' WHERE
VEHICLE = 63'.  With the post method of the dataset how do I set the
where condition?
Thanks,
Jim (jmille...@hotmail.com)
 

Re:How to post an update to ADO dataset with where condition.


I'm pretty new to Delphi 6/ADO so don't quote me on it, but you could hook
up an ADOCommand component to your ADOConnection, set its 'command text'
property to the SQL update text you want, and use the execute method for the
ADOCommand. You may then need to do a refresh on your ADODataset component
to refresh the dataset.

I think you can also use the command text in the ADODataset and then post
it. But that may be a hassle if you need to keep putting your old query and
dataset back afterwards. There may well be a better way, to do it directly
programatically.

Maybe someone else will post on that! <g>

Hope this helps.

Lauchlan M.

Quote
"Jim Miller" <jmille...@hotmail.com> wrote in message

news:3c1d255f.25766303@forums.borland.com...
Quote
> I have an ADO dataset and want to update a field with the post method.
> With a SQL statement I would 'UPDATE MDCOUT SET DRIVER =  'JOHN' WHERE
> VEHICLE = 63'.  With the post method of the dataset how do I set the
> where condition?
> Thanks,
> Jim (jmille...@hotmail.com)

Re:How to post an update to ADO dataset with where condition.


Please don't multi-post a question, it's against newsgroups directives.
bye

Quote
Jim Miller wrote:
> I have an ADO dataset and want to update a field with the post method.
> With a SQL statement I would 'UPDATE MDCOUT SET DRIVER =  'JOHN' WHERE
> VEHICLE = 63'.  With the post method of the dataset how do I set the
> where condition?
> Thanks,
> Jim (jmille...@hotmail.com)

--
Guillermo Casta?o Acevedo
Gerente de Sistemas - Grupo Millennium Ltda
Guiller...@GrupoMillennium.com
www.GrupoMillennium.com

Re:How to post an update to ADO dataset with where condition.


Sorry. It was a mistake.  I had my date set to the wrong date.
Jim
On Sun, 16 Dec 2001 20:46:30 -0500, Guillermo
Quote
=?iso-8859-1?Q?Casta=F1o?= A <Guiller...@GrupoMillennium.com> wrote:
>Please don't multi-post a question, it's against newsgroups directives.
>bye

>Jim Miller wrote:

>> I have an ADO dataset and want to update a field with the post method.
>> With a SQL statement I would 'UPDATE MDCOUT SET DRIVER =  'JOHN' WHERE
>> VEHICLE = 63'.  With the post method of the dataset how do I set the
>> where condition?
>> Thanks,
>> Jim (jmille...@hotmail.com)

>--
>Guillermo Casta?o Acevedo
>Gerente de Sistemas - Grupo Millennium Ltda
>Guiller...@GrupoMillennium.com
>www.GrupoMillennium.com

Re:How to post an update to ADO dataset with where condition.


Hi Jim,

Quote
> I have an ADO dataset and want to update a field with the post method.
> With a SQL statement I would 'UPDATE MDCOUT SET DRIVER =  'JOHN' WHERE
> VEHICLE = 63'.  With the post method of the dataset how do I set the
> where condition?

If i understand you well, you could do this:
Set the Filter to 'VEHICLE = 63'.
Set Filtered to True.
Navigate through the dataset:

 YourADODataSet.First;
 While not YourADODataSet.EOF do
   begin
   YourADODataSet.FieldByName('DRIVER').Value := 'JOHN';
   YourADODataSet.Post;
   YourADODataSet.Next;
   end;

Set Filtered to False.
Set Filter to ''.

But you see that it is much less easy (and probably slower) than with a
SQL command.

If you know that you have only one record that meets the WHERE
condition, you don't need a loop and you can just use Locate to find it
.

Thrse

Other Threads