lue
Posts: 20
|
Posted: 11/16/2006, 1:41 AM |
|
How can i update two forms in the same page (vb.net) with only one submit button?
thanks for any good idea!
Chris
|
|
|
Diesel
Posts: 43
|
Posted: 11/30/2006, 1:46 AM |
|
Hi there
I was struggling with this exact same problem a few months ago. There is no real way that I have come across to do a multiple update on two or more record forms. I have googled, gone onto quite a few forums, dev sites etc with no help.
How did I get around it?
Simple actually
Lets say you have 3 record forms on your page. All you need to do is remove the Allow Insert/Update/Delete actions from 2 of the record forms thus leaving only one record form with a submit action on Insert/Update or Delete.
Now you can complete all the fields in all the record forms as required and then do an Insert or update on the onclick event of the record form with the submit button.
Remember that all controls have a unique name at runtime... so lets say you have a textbox with the name txtExample and the Record Form name is frmRecordExample then the equivalent runtime name for your textbox would be: frmRecordExampletxtExample
and for Record2
txtExample and the Record Form name is frmRecord2Example then the equivalent runtime name for your textbox would be: frmRecord2ExampletxtExample
Now with keeping that in mind you can do a insert or update through normal conventional code and submit the values to the database. Lets take an insert for example:
On the onclick event (server side) of the button on Record Form 3:
'WHERE <ConnectionName> is your Connection Name & <table> your table name & <field> your field name
Dim NewDao As DataAccessObject = Settings.<ConnectionName>DataAccessObject
'For Record 1
Dim SqlInsert As String = "INSERT INTO <table>(<field>) " & _
"VALUES ('"& frmRecordExampletxtExample.Text &"'")
NewDao.RunSql(SqlInsert)
'For Record 2
Dim SqlInsert As String = "INSERT INTO <table>(<field>) " & _
"VALUES ('"& frmRecord2ExampletxtExample.Text &"'")
NewDao.RunSql(SqlInsert)
========================================================================
If Record 3 is setup correctly the third Records insert statement should work automatically.
I hope this helps!
Zack
|
|
|
Xcar
|
Posted: 01/24/2007, 7:25 AM |
|
hi there,
i have the same problem but with php , i need update two record with one button someone can help me ? thank
|
|
|
|