Note that there are some explanatory texts on larger screens.

plurals
  1. PO"key violation" autoincrement field in ClientDataSet [Delphi]
    primarykey
    data
    text
    <p>this is my third question here, so far excellent responses ^^</p> <p>I'm having no problems in browsing, editing the data, but insertions...</p> <p>Here is my doubt: In a finance/stock software i have a form to create a new order,<br> naturally i need to insert a new row in <strong>t_orders</strong> table<br> and insert items in <strong>t_orderitems</strong> table with <strong>orderId</strong> field linked to a row in <strong>t_orders</strong> </p> <pre><code>CREATE TABLE `t_orders` ( `orderId` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `clientId` INT(10) UNSIGNED NOT NULL, ...) CREATE TABLE `t_orderitems` ( `orderitemId` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `orderId` INT(10) UNSIGNED NOT NULL, ...) --&gt; INDEXES AND FOREIGN KEYS OMITTED &lt;-- </code></pre> <p>How do i add itemorders to a grid and finally in "FinalizeOrder" button click </p> <ul> <li>Create an order in <strong>t_orders</strong></li> <li>Insert items in <strong>t_orderitems</strong> linked to that order</li> </ul> <p>Connection is made using ADO.</p> <p>I'm not sure if it's possible to do like this, in that case, how i should do?</p> <p>edit: I tried using nested ClientDataSets and it works in parts, but i still don't know how to get the inserted Order Id</p> <p><strong>edit2:</strong><br> <em>Now i have another problem, i can't add more than one item into the ClientDataSet.<br> Because OrderItemId is empty for all items (i can only get that values upon database insertion), when i attempt to add a second item it gives me Key Violation, any ideas??</em></p> <p><em>If i set Updatemode to something different than upWhereKeyOnly and set pfInKey to False it works but i don't think it's an option</em></p> <p><em>Any ideas?</em></p> <p>Thanks in advance!<br> Arthur.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload