close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

2 inserts with differing IDs?

Thread began 4/05/2012 10:25 am by gary.brett434358 | Last modified 4/13/2012 9:32 am by Jason Byrnes | 859 views | 6 replies |

gary.brett434358

2 inserts with differing IDs?

Hi, hope this make some kind of sense, using DA I have a form which on submit inserts values to two tables. tbl1 is a contacts table whereby it adds a contact and contactid [autonumber], tbl2 is an events table whereby it creates a diary event, contact name, conactid and eventid.

Is there a way I can have identical ContactID in both tables to bind the contacts? When insert into tbl1.contactid the ContactID is say 100, insert into tbl.contactid sets its as next number which could be 12, would be great to have both tables store same.

Example:
tbl1 - 100 - John Smith
tbl2 - 100 - John Smith

I had thought maybe inserting to tbl1 first then somewhow using a session to insert the newly created ContactID into tbl2.conactid field?

Confused!

Sign in to reply to this post

Jason ByrnesWebAssist

each table should have it's own unique ID column that is set to auto increment.

in the second table, you can create a relationship column that will store the ID of the record inserted to table1.

for example:

contacts:
contactID - primary Key, Auto Increment
contactName - text
etc....


events:
eventID - primary Key, Auto Increment
eventContactID - relates to contacts.contactID
evantName - text
etc....

in the data assist insert behavior, look in the Session Variable section, this sets a session variable that will contain the id of the record that was inserted.

in the second insert behavior, you can bind the relationship column to the session variable created by the first insert behavior

Sign in to reply to this post

gary.brett434358

Thanks Jason, that's sorted a treat.

Regards

Gary

Sign in to reply to this post

Jason ByrnesWebAssist

you're welcome

Sign in to reply to this post

karey307024

Same basic question

Yes, this is just what I'm looking for, Jason. I do have the database tables set up correctly, and need to be able to insert into the second table the ID just created by the auto incrememt feature of the insert from the first.

For the first insert, I used the Data Assist Wizard, and I'm not seeing the Insert Behavior in the Behaviors Panel. How do I use a second insert behavior for the second table and grab the userID just created by the first insert?

Sign in to reply to this post

gary.brett434358

Hi there, if you used the DA wizard to create your pages did you choose to create an insert page? If so then the insert behaviour should appear on the details page? If you open that up and copy the session value, then manually create the 2nd insert wizard using DA insert behaviour. After that's done you should be able to paste in the session value of the first insert into the matching field in 2nd table..

I'm sure Jason, will clarify better than I can but hope it helps in someway..

Sign in to reply to this post

Jason ByrnesWebAssist

Make sure you are looking in the "Server Behaviors" panel, this is where you will find the Insert Record server behavior.

The "Behaviors" panel is where you will find Client Side behaviors.

mak sure that the first insert does not have a redirect set, and make note of the name of the session to be created.

Go to the bindings panel, and expand the session collection, make sure there is a binding there for the session created by the first insert. if not, click the plus button, select Session variable to create the binding.

you can then add the second insert behavior by clicking the plus button on the server behaviors panel, and selecting DataAssist -> Insert Record -> Insert Single record.

bind the relational column of your table to the session variable.

Sign in to reply to this post

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...