Recent

Author Topic: Copying Zeos Dataset  (Read 10051 times)

MainMeat

  • New Member
  • *
  • Posts: 18
Copying Zeos Dataset
« on: April 30, 2009, 11:33:46 am »
Hi Everyone,

I am using the Zeos DBO components and have a question on datasets
Does anyone know how I can copy the data from one dataset to another? Simply using:
Dataset1 := Dataset2
does not resolve the problem, since the moment you close Dataset1, Dataset2 is also closed.

Also, any idea how I can insert new Records into a Dataset that already exists in the database. For example I have a database with 3 record, but only populate the dataset with record 1 and 2. Later at runtime I insert record 3 (from the application), but when trying to write the dataset to the database I get an access violation on the promary key because record 3 already exists and cannot be inserted again.

Thanks for any advice!

mesavage

  • Newbie
  • Posts: 1
Re: Copying Zeos Dataset
« Reply #1 on: June 10, 2009, 12:55:54 pm »
That is because you are not using Zeos correctly, well infact, you are not using any db correctly if your going about it in that way.

What your trying to do, it would seem is setup a master/detail relationship, for that you create one Datasource and then have both tables pointing to it using the mastersource variable.

If you are trying to copy one table to another, you might want to do a while loop, but this is where you don't understand how it works. You assign both Datasets to the same database object/table, not to each other.

I am for now assuming you are using mysql/sql for your database, to update a record that already exists with new information, you need to set the table/dataset to Edit mode ie: ZTable1.edit; and then after assigning the values to the fields, you do a ZTable1.post; to store the new information.

What you need is a redundancy check, Activate the table, check if the record already exists, if it does use table.edit if it does not use table.insert. IF ELSE go go go.

hope that helps :P

Luciano

  • New Member
  • *
  • Posts: 19
Re: Copying Zeos Dataset
« Reply #2 on: July 27, 2009, 12:48:32 pm »
Dear, (sorry by my english, becaus i'm a brazilian, sorry too for posting here, but could not find option to post somewhere else ...)

I will installed Lazarus, the Zeos and Firebird on my laptop. The OS is Ubuntu 9:04.
I can run applications in Lazarus and can also create databases with the Firebird via terminal.

I wonder if anyone can help me the following problem:
When I put a componte ZConnection, I usually connect it to the database, but when you put a Ztable and try to change the Active property to true is the error of the access violation.

Any suggestions at least that part I can go to get help?

Thank you.

Lord_ZealoN

  • Full Member
  • ***
  • Posts: 141
    • http://lordzealon.com
Re: Copying Zeos Dataset
« Reply #3 on: July 27, 2009, 01:11:47 pm »
Dear, (sorry by my english, becaus i'm a brazilian, sorry too for posting here, but could not find option to post somewhere else ...)

I will installed Lazarus, the Zeos and Firebird on my laptop. The OS is Ubuntu 9:04.
I can run applications in Lazarus and can also create databases with the Firebird via terminal.

I wonder if anyone can help me the following problem:
When I put a componte ZConnection, I usually connect it to the database, but when you put a Ztable and try to change the Active property to true is the error of the access violation.

Any suggestions at least that part I can go to get help?

Thank you.

Has you libfbclient installed?

Luciano

  • New Member
  • *
  • Posts: 19
Re: Copying Zeos Dataset
« Reply #4 on: July 27, 2009, 02:47:59 pm »
I will check and post the results here. Thanks

Lord_ZealoN

  • Full Member
  • ***
  • Posts: 141
    • http://lordzealon.com
Re: Copying Zeos Dataset
« Reply #5 on: July 27, 2009, 03:17:18 pm »
I will check and post the results here. Thanks

I think is better thath you open a new thread, to avoid to merge 2 different question ;) (sorry for not tell you before)

 

TinyPortal © 2005-2018