Recent

Author Topic: [SOLVED]how can i edit databank fildes with zeos ??  (Read 4958 times)

majid.ebru

  • Sr. Member
  • ****
  • Posts: 494
[SOLVED]how can i edit databank fildes with zeos ??
« on: May 21, 2017, 08:48:57 pm »
Hi

after i see this clip
i build a databank and write a data into databank.

but now i want to edit(updata) some fildes of bank with zeos.
can anybody help (and guide) me ??
« Last Edit: July 01, 2017, 12:35:01 pm by majid.ebru »

marsupilami79

  • New Member
  • *
  • Posts: 32
Re: how can i edit databank fildes with zeos ??
« Reply #1 on: May 21, 2017, 09:25:38 pm »
Hello,

what code do you have already? What works for you and what doesn't work?

Usually you can go two ways:

If you want to update data that you already have loaded into your dataset:
Code: [Select]
ZQuery.Edit;
try
  ZQuery.FieldByName('x').asString := 'a';
  ZQuery.FieldByName('y').asnteger := 5;
  ZQuery.Post;
except
  ZQuery.Cancel;
  raise;
end;

If you just want to execute an update statement do something like this:
Code: [Select]
ZQuery.SQL.Text := 'update table set x = :param_x where y = :param_y';
ZQuery.ParamByName('param_x').asString := 'a';
ZQuery.ParamByName('param_y').asInteger := 5;
ZQuery.ExecSQL;

With best regards,

Jan
Zeos developer

majid.ebru

  • Sr. Member
  • ****
  • Posts: 494
Re: how can i edit databank fildes with zeos ??
« Reply #2 on: May 22, 2017, 02:21:17 pm »
thanks


Code: [Select]
ZQuery.Edit;
try
  ZQuery.FieldByName('x').asString := 'a';
  ZQuery.FieldByName('y').asnteger := 5;
  ZQuery.Post;
except
  ZQuery.Cancel;
  raise;
end;

it is very good

but which row do you edit that?!
.
my bank has for example 10 rows.

how can i edit(updata) 10th row?

or
.
i want to edit my row click on dbgrid?
.
i want to edit(updata) 5th row?
.
how can i edit(updata) 5th row?
« Last Edit: May 22, 2017, 02:33:33 pm by majid.ebru »

majid.ebru

  • Sr. Member
  • ****
  • Posts: 494
Re: how can i edit databank fildes with zeos ??
« Reply #3 on: May 23, 2017, 04:50:57 am »
for example :

how can i edit 4th row?
.
thank you

majid.ebru

  • Sr. Member
  • ****
  • Posts: 494
Re: how can i edit databank fildes with zeos ??
« Reply #4 on: May 23, 2017, 11:47:33 pm »
Hi

please help me

i know that i am beginner and my question is very very Primary , but i need answer .

thanks a lot

SunyD

  • Guest
Re: how can i edit databank fildes with zeos ??
« Reply #5 on: May 24, 2017, 12:38:45 am »
Hello,

what code do you have already? What works for you and what doesn't work?

Usually you can go two ways:

If you want to update data that you already have loaded into your dataset:
Code: [Select]
ZQuery.Edit;
try
  ZQuery.FieldByName('x').asString := 'a';
  ZQuery.FieldByName('y').asnteger := 5;
  ZQuery.Post;
except
  ZQuery.Cancel;
  raise;
end;

If you just want to execute an update statement do something like this:
Code: [Select]
ZQuery.SQL.Text := 'update table set x = :param_x where y = :param_y';
ZQuery.ParamByName('param_x').asString := 'a';
ZQuery.ParamByName('param_y').asInteger := 5;
ZQuery.ExecSQL;

With best regards,

Jan

This code was right.
TDataset (TZQuery, TSQLQuery is derived from it) shows only one Datarow. It is in TDBGrid marked with arrow (Indiciator column).
If you want edit other data row then you must first move your db-cursor with TDataset.Prior, TDataset.Next or TDataset.locate commands.
I think you need database basics, look at are:
http://wiki.freepascal.org/Lazarus_Database_Overview
Follow the tutorials, specially this one http://wiki.freepascal.org/SQLdb_Tutorial1

I would advice you to use built in SQLDB components not the ZEOS components.
SQLDB components have more informations.

Most people like me are using ZEOS only because they come from Delphi and know ZEOS components. SQLDB is future, ZEOS past.


majid.ebru

  • Sr. Member
  • ****
  • Posts: 494
Re: how can i edit databank fildes with zeos ??
« Reply #6 on: May 24, 2017, 01:03:18 am »
thank you very much
 :-* :-* :-* :-*

miab3

  • Full Member
  • ***
  • Posts: 145
Re: how can i edit databank fildes with zeos ??
« Reply #7 on: May 24, 2017, 10:00:25 am »
TDataset (TZQuery, TSQLQuery is derived from it) shows only one Datarow. It is in TDBGrid marked with arrow (Indiciator column).
If you want edit other data row then you must first move your db-cursor with TDataset.Prior, TDataset.Next or TDataset.locate commands.

or TDataset.MoveBy(+-z)
Code: Pascal  [Select][+][-]
  1. ZQuery1.First;
  2. ZQuery1.MoveBy(5);
  3. ZQuery1.Edit;
  4. //...
  5. ZQuery1.Post; // or ZQuery1.Next;
  6.  
  7. //// or
  8. ZQuery1.Insert;
  9. //...
  10. ZQuery1.Post;
  11.  
  12. //// or
  13. ZQuery1.Delete;
in AutoCommit mode.

Michal
« Last Edit: May 24, 2017, 10:31:52 am by miab3 »

majid.ebru

  • Sr. Member
  • ****
  • Posts: 494
Re: how can i edit databank fildes with zeos ??
« Reply #8 on: May 24, 2017, 02:12:02 pm »
TDataset (TZQuery, TSQLQuery is derived from it) shows only one Datarow. It is in TDBGrid marked with arrow (Indiciator column).
If you want edit other data row then you must first move your db-cursor with TDataset.Prior, TDataset.Next or TDataset.locate commands.

or TDataset.MoveBy(+-z)
Code: Pascal  [Select][+][-]
  1. ZQuery1.First;
  2. ZQuery1.MoveBy(5);
  3. ZQuery1.Edit;
  4. //...
  5. ZQuery1.Post; // or ZQuery1.Next;
  6.  
  7. //// or
  8. ZQuery1.Insert;
  9. //...
  10. ZQuery1.Post;
  11.  
  12. //// or
  13. ZQuery1.Delete;
in AutoCommit mode.

Michal
thank you very much
 :-* :-* :-* :-*

 

TinyPortal © 2005-2018