CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> General/Other

 How to get parent id to insert into child record

Print topic Send  topic

Author Message
Mike
Posted: 04/30/2004, 9:11 AM

I have 2 forms. One is an editable grid child of records.
When I try to insert a child record I get the following error: PostgreSQL Error: 1 (ERROR: null value in column "people_id" violates not-null constraint ). I need to add the parent record id to the insert statement.How do I do that?
peterr


Posts: 5971
Posted: 04/30/2004, 11:59 AM

This looks similar to our Master-Detail examples in CCS Example Pack.
For example at http://examples.codecharge.com/ExamplePack/OrderEntry/O....php?order_id=3 when you add a new Item then it is added as a child record for the currently selected order. This was implemented by adding hidden field to the Editable Grid that contains the order_id.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
mike
Posted: 04/30/2004, 12:43 PM

When adding a record to a grid the fields are empty
How do get the value in the hidden field into the insert statement
Thanks
peterr


Posts: 5971
Posted: 04/30/2004, 1:23 PM

Take a look at that example, especially the "Data Source" property of that grid.
The Web users must specify somehow which parent record they are working with and this is usually done by the users selecting some record in the parent grid first, and then the URL would contain that parent record just like the URL http://examples.codecharge.com/ExamplePack/OrderEntry/O....php?order_id=3 contains "order_id=3".
You can then use this parent record's id in a variety of ways, either to populate the hidden field, or to utilize WHERE statement that says "WHERE order_id = (parameter value)" as shown in our example.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
peterr


Posts: 5971
Posted: 04/30/2004, 1:53 PM

I just took a look at that sample project and I see that the value of the hidden field (order_id) is set in the "Before Build Insert" event using this code (ASP):
If not isEmpty(request.QueryString("order_id")) Then
store_orders_items.DataSource.order_id.Value = request.QueryString("order_id")
End If


This means that order_id is set to the value of the URL parameter with the same name (order_id).

You didn't specify which programming language you use but you can find equivalent code in any programming language if you look at that example project.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.