473,499 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SqlDataSource multiple table insert

Hi,

Would be grateful if anyone with a high understanding of the
SqlDataSource and FormView could have a look at my example and my
problems.
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
details.
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 http://www.developersdex.com ***
Aug 29 '06 #1
0 1755

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
5012
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my...
3
8913
by: Wayne Wengert | last post by:
Using VSNET2005. I want to insert some rows into a table. Each row has 2 columns, "memberid" which is a GUID and "Interests" which is a varchar. I created a SQLDataSource with the values to insert...
2
9875
by: Ned Balzer | last post by:
I'm trying to create a formview bound to a sqldatasource, and use a stored procedure to insert data from the formview into several tables. I have some simplified code below, the real code is much...
3
2937
by: djc | last post by:
I am playing with the (new to me) sqlDataSource class. I used it to bind data from a database table into a listbox with no code, worked great. Now I need to do an INSERT for every item in a...
1
2246
by: ssims | last post by:
I'm working with ASP.Net on IIS 5.1 and MSSQL 2000 and have a rather frustrating problem. I'm trying to insert a record to a table, get the identity value, and insert two additional records to a...
1
6112
by: sheenaa | last post by:
Hello Members, I m creating my application forms in ASP.Net 2005 C# using the backend SQL Server 2005. What i have used on forms :: ? On my first form i have used some...
2
4057
by: Joe Kovac | last post by:
Hi! The informations of our customers are saved in two tables: Customer: ID, CustomerNumber, ... + Person_ID Person: ID, Name, ... I want to have an editable GridView displaying all the...
4
6119
by: =?Utf-8?B?TWFkaXNvbg==?= | last post by:
Hi all, Could I use the sqldatasource with stored-procedure to return multiple recordset? I did not want to have any sqldatasourec in the one page just to return the record back to...
0
3610
by: dhyder | last post by:
I'm working on an admin page for a SQL Server 05 db. The page is in ASP.NET 2.0/C#. The db has multiple tables with foreign keys/constraints. I have multiple SqlDataSources and GridViews, which...
0
7130
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7386
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5468
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.