By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,953 Members | 1,524 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,953 IT Pros & Developers. It's quick & easy.

SqlDataSource multiple table insert

P: n/a

Would be grateful if anyone with a high understanding of the
SqlDataSource and FormView could have a look at my example and my
This has really been puzzling me for some time, and would like and
expert just to confirm what I am doing is the best approach.

Application example:

1 web form allowing user to enter personal details as well as bank
Personal details are held in one Database table (tblAccount), bank
details held in another (tblBank).

The technique I use to save the details to the database are as follows:

1. Create a SqlDataSource
2. Bind the SDS to a FormView (the FormView has all the personal and
bank details)
3. The SDS has an Insert command which inserts a row to the tblAccount
table (I added a ;Select @@identity on the end)
4. The FormView has a Button with its Command property set to Insert
5. On Clicking the Insert Button, the Inserted event gives me access to
the the newly insert Primary Key
(return value of original Select statement)
and I then perform a second insert using the remaining parameters
that have been collected after the Insert button is clicked
6. This whole process is wrapped in a Transaction from the orignal
command object built after the Insert button was clicked.

Can anyone suggest an alternative to this approach?

The process of the Command object being built after I click Insert
button is automated.
Is there some way the developer can invoke this manually?

What would be nice is one web page to have two FormViews, one for
Personal and Bank.
The problem is the building of the command object. The only way I can
currently do this is to have a
Insert button on each FormView and verify the user presses both buttons.
This is not acceptable.
Is there a way when I call click the Bank FormView Insert, that it
somehow "calls" the Insert Click on Personal FormView?

*** Sent via Developersdex ***
Aug 29 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.