473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Multiple Inserts with SQLDataSource

I am looking for some advice on the following problem:

I am using a GridView and a SQLDataSource.

The problem is based around a Room Booking app I am currently writing.

When the user makes a booking, an entry must be written to the Booking
table, and x amount of entries to the BookingXref(the room keys are held
here)

How can I write muliple Inserts using a SQLDataSource in such a way that
I rollback any errors (is it possible to wrap many SQLDataSource.Inserts
in a transaction) or can someone suggest another way of doing this?

I would have used a Stored Procedure, but the rooms are variable.

Any help on this would appreciated.

Regards,

Steven

*** Sent via Developersdex http://www.developersdex.com ***
Nov 20 '05 #1
4 3106
Take a look at the SqlTransaction class. You get it by calling
SqlConnection.BeginTransaction() at the beginning of your series of updates.

Call SqlTransaction.RollBack() if there's an error.

When the connection closes, the transaction will commit, or you can
specifically call SqlTransaction.Commit().

Pete

"Steven Blair" <st**********@btinternet.com> wrote in message
news:e7**************@TK2MSFTNGP12.phx.gbl...
I am looking for some advice on the following problem:

I am using a GridView and a SQLDataSource.

The problem is based around a Room Booking app I am currently writing.

When the user makes a booking, an entry must be written to the Booking
table, and x amount of entries to the BookingXref(the room keys are held
here)

How can I write muliple Inserts using a SQLDataSource in such a way that
I rollback any errors (is it possible to wrap many SQLDataSource.Inserts
in a transaction) or can someone suggest another way of doing this?

I would have used a Stored Procedure, but the rooms are variable.

Any help on this would appreciated.

Regards,

Steven

*** Sent via Developersdex http://www.developersdex.com ***

Nov 20 '05 #2
Yeah I have seen this class before, but the problem is how to I get this
to interact with my SQLDataSource :|

I was hoping to use this SQLDataSource and somehow manage the multiple
inserts.
*** Sent via Developersdex http://www.developersdex.com ***
Nov 20 '05 #3
If you're talking about the SQLDataSourceControl included with WebMatrix, I
have no idea how it works or what it supports, but I suspect, if it's a
wrapper for the data access that it's probably not going to give you that
level of control. I could be wrong, but I just don't know anything about it.

Pete

"Steven Blair" <st**********@btinternet.com> wrote in message
news:eI**************@TK2MSFTNGP11.phx.gbl...
Yeah I have seen this class before, but the problem is how to I get this
to interact with my SQLDataSource :|

I was hoping to use this SQLDataSource and somehow manage the multiple
inserts.
*** Sent via Developersdex http://www.developersdex.com ***

Nov 20 '05 #4
its the SQLDataSource for 2005. You drag it on your web form and can
bind a GridView to it. I just need to know how to handle a situation
where I need to make more than one INSERT statement.
*** Sent via Developersdex http://www.developersdex.com ***
Nov 20 '05 #5

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

Similar topics

2
by: Joe | last post by:
Hey, I'm going to give some background on my situation in case anyone can point out a way around my problem altogether... for the problem itself, please skip to the bottom of the post. thanks....
2
by: Dabbler | last post by:
In some cases I would like to allow a user to select a row from a GridView to update in another page using a DetailsView form (passing the key in QueryString). In other cases I would like to use...
0
by: Nam | last post by:
I want to use the same sqlDataSource for two CheckBoxList controls in ASP.NET 2.0. For simplicity, I am using the case of only two CheckBoxList controls in the following example: My...
0
by: Steven Blair | last post by:
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...
0
by: joebob8000 | last post by:
This seems like a simple task, but my 6 year old roots in classic ASP must be causing me trouble with my current problem. I am looking to provide a search for users in which they can select...
1
by: rosie2006 | last post by:
Environment: .net2.0 over oracle Problem? a simple select statement within a DetailsView that gets two parameter values from a GridView SelectedValue. It might be valuable to understand that to...
4
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
by: suganya | last post by:
Hi I have a GridView in my Page. I have to bind multiple tables into the GridView using SQLDataSource. For that I have given the coding as <asp:GridView ID="Search_GridView" runat="server"...
58
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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...

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.