473,836 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.Net [2.0] Parameters with mass insert

Hi all,

I thought I was being clever - no I'm doubting my abilities :o(

My project reads in the content from an XML file, this is made up of a
series of "courses", each "course" has a series of items.

As I bring in the data I map it all off to my own classes, and add each
Course class to my collection of courses.

once I have them all I need to dump them to SQL Server.

I create a connection, command, transaction and assign them all accordingly,
however, my problem is that as I iterate through each Course in the
collection I dont want to "commit" the transaction until I've gone through
them all (incase anything screws up), so at the end of the iteration if
everything is ok - it commits, if not - it'll rollback.

My problem is on the second iteration, it realises that the calls to my
stored procedures have already used parameter names which are now trying to
be used again, the result is a "The SqlParameter is already contained by
another SqlParameterCol lection." error message.

Anyone got any ideas on how to approach this problem? I'm calling 4 stored
procedures multiple times, they are:

AddCourse (adds the basic components of a course to the Course table)
AddObjecives (adds a product code and text item to the Objectives table)
AddFeatures (adds a product code and text item to the Features table)
AddPreRequisite s (adds a product code and text item to the PreRequisites

It all seems ok - until it starst the second iteration of the Course
collection - where presumably there is already a @ProductCode parameter in
my parameters collection...

If I was to comit after each "Course" instead of after all of them this
would obviously get around this problem, but my understanding is that then,
if out of the 1588 courses that should be written to the database, if
something screwed up around the 800 mark, I'd have 799 in the database and
the last lot wouldn't go in...

I could of course write code to check to see if they are already in the
database first, but I'd rather do a "wipe the lot, insert the lot" kind of

Any information would be appreciated.


May 29 '06 #1
1 1243
"Rob Meade" wrote ...


Turns out I wasn't clearing/deleting the Parameters object before iterating
back through - duh...

May 29 '06 #2

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

Similar topics

by: Lauren Quantrell | last post by:
Is it possible the existence of a return parameter on an SP running insert statements would cause blocking to happen (any removing it might help eliminate it?) The SPs in question have three INSERT INTO statements using an @@IDENTITY to help populate the second and third tables based on the PK of the newly inserted record in the first INSERT INTO Statement. I have recently stared to receive timeout errors in a multi-user enviroment and...
by: kartik | last post by:
Hi , I am in need to find a way, to mass copy the data from db2 table running in mainframe to universal database db2 on NT. I know that DB2 connect gives the flexiblity of connecting and communicate the db2 application running in mainframe. but i want to know that whether i can do mass transfer data between the two system . i like to do as a night job that runs for many hrs.I like to know any protocol is used for such connectivity and...
by: mp | last post by:
No value given for one or more required parameters. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.OleDb.OleDbException: No value given for one or more required parameters. Source Error:
by: pjcraig | last post by:
This is driving me crazy! I have a form that a user will access from another form by selecting the item that they wish to view. When they open the new form, I pass through the id of the item they selected so that only the details for the given item are displayed. In order for this to work, I using the following code.... This is working no problems at all: SqlSelectCommand1.Parameters("@blast_no").Value = blastNo So this displays the...
by: anilcool | last post by:
Hi all, Another novice question. I want to insert multiple records into my DB2 database using stored procedure but I do not know how many I would like to insert at any given time. Each record has 6 columns (fields). Here's an example of a stored procedure that accepts 6 parameters and inserts one record. I would like to modify this stored procedure such
by: teo | last post by:
Hallo, I'm performing a mass insertion from a text file to a db table with AdoNet commands, like this: myCommand.CommandText = "BULK INSERT ..." from a Win form no problem
by: Choronzon | last post by:
What commands do i need to start looking into, to complete a mass insert of info into a database. im looking to insert something like this: player_name | player_id | location I want to have a large HTML text field were i can enter multiple lines like this and then have them inserted into the proper tables/fields. Im just looking for a basic theory and commands here so i can start to research and try some simple coding in this area.
by: AxleWacl | last post by:
Hi, The below error is what I am receiving. The code im using is below the error, for the life of me, I can not see where any parameter is missing..... Server Error in '/FleetcubeNews' Application. -------------------------------------------------------------------------------- No value given for one or more required parameters. Description: An unhandled exception occurred during the execution of the current web request. Please...
by: DaveL | last post by:
Hello I want to build Dynamic Paramers for a Sql Insert below is what i have so far but...determinthe column type and length im having Problems with Tks dave string sInsert = "Insert into oaDental..dentalClaims (";
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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...
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...
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();...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.