473,624 Members | 2,612 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 1764

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

Similar topics

8
5029
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 select, remember it, and then use it in the update. It works just fine when I have full control of the whole process. I want to do the same for my GridView/SqlDataSource combinations. I typically select from a view and update the corresponding...
3
8926
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 as parameters as shown here ===================================================== <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:GoodSamSiteDB %>" DeleteCommand="DELETE FROM WHERE = @memberid...
2
9889
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 longer but this should illustrate the problem: <asp:FormView ID="bookFormView" runat="server" DataSourceID="bookSqlDataSource"> <ItemTemplate> <asp:textBox id="name" text='<%# Eval("name") %>'
3
2948
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 listbox. I used to just code the ado stuff myself in .net 1.1. For example creating connection object, creating sqlCommand object, parameters, etc... I would just create the ado stuff, then loop through the listbox changing the sqlcommand parameter...
1
2255
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 second table. My insert command looks like this: INSERT INTO TableA VALUES(PK_NameID, CQ1, CQ2, CQ3, CQ4); DECLARE @ID int; SET @ID = SCOPE_IDENTITY(); INSERT INTO TableB VALUES(@ID, IQ1, IQ2, IQ3, IQ4); INSERT INTO TableB VALUES(@ID, IQ1,...
1
6124
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 label,textboxs,dropdownlists,radiobutton and checkbox asp standard controls. On the click event of the command button the data gets stored into the database. I have created the stored procedures for the insert,update,delete. I have...
2
4067
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 data and being able to add, edit and delete customers.
4
6127
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 dropdownlists. In my stored procedure will have 2 select statement. If it can be done how I refer to each dropdownlist to correct recordset. Please advise. Thanks.
0
3618
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 are doing the select/update/delete methods. I manually did the Insert method for each Gridview and I am able perform error handling on it. Textboxes for data to add <asp:Button ID="btnInsertNewService runat="server" Text="Submit"...
0
8246
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8631
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8490
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7174
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2612
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 we have to send another system
2
1489
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.