close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

insert into two tables

Thread began 5/12/2010 7:12 am by mr hankey | Last modified 6/11/2010 7:33 am by Jason Byrnes | 4542 views | 15 replies |

mr hankey

insert into two tables

Hi,

How would i use Data Assist to insert into two tables at once?

I need to be able to insert into the products table and at same time insert the amount into the payments table?

Many thanks

Sign in to reply to this post

Jason ByrnesWebAssist

Use two Insert record behavior on the page, one to perform the insert to the products tabel, the second to insert to the payments table.

Sign in to reply to this post

tom92909Beta Tester

You have (2) tables

products
payments

You can have one page that does both entries to the tables. You'll need a form that performs a POST to store the data to your tables. The submit button will trigger the store action.

Create (2) separate INSERT behaviors for each table triggered off of the same submit button.

Sign in to reply to this post

mr hankey

hey thanks for that, the payments fields are hidden and need to get the values from the products insert i.e. amount

will that work with the two server behaviours off one submit button?

thanks again

Sign in to reply to this post

Jason ByrnesWebAssist

yes, you can use the two insert behaviors and trigger them off the same submit button.

Sign in to reply to this post

mr hankey

thanks tom92909 and jason, having trouble implimenting.

i added the second insert behavior to my form however it comes back when i insert with:

Column 'ProductID' cannot be null

the ProductID should get is value from the InsuranceID which i have set it to by clicking the lightning bolt and selected my hidden form field InsuranceID in my form.

I am guessing that because it does not get a value until it inserts into the database this is why it shows as null in my ProductID ?

any ideas how to get around this?

thanks guys

Sign in to reply to this post

Jason ByrnesWebAssist

If the first Insert record behavior insert to the Insurance table, it will store the insurance ID in a session variable.

In the second insert record behavior, you should bind the product id column to the session variable created by the first insert record behavior.

Sign in to reply to this post

victor278184

just an addition info.. if you like to know what the session name that stored the last insert id, you could look at the source code and find something like this:

$WA_sessionName = "WADA_xxxxxxxxxxxx";

if you have multiple form in a page... this method will be helpfull since DataAssist create Session binding in every insert record behavior.

Sign in to reply to this post

mr hankey

thanks guys, so will it get it from the session variable even if they are both triggered on the same submitt button?

is there a way to set the order of the inserts or does that not matter?

thanks again

Sign in to reply to this post

Jason ByrnesWebAssist

yes it will still set the session.

The order they are added to the code is the order you add them.

add the insert record behavior for the parent table first, then add the insert record behavior for the child table.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...