473,758 Members | 2,311 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple insert.

greetings, i'm doing a multiple insert into the db through a store proc. i'm
very sure the sp has nothing wrong. below are my implementation code and
error msg. thanks in advance for the help

objCmd.Connecti on = objConn
objCmd.CommandT ype = CommandType.Sto redProcedure
objCmd.CommandT ext = "pr_AUDIT_UPLOA D_UpdateStkCntA ud"

With objds.Tables(0)
For intx = 0 To .Rows.Count - 1
objCmd.Paramete rs.Add("@InsId" , SqlDbType.BigIn t).Value
= .Rows(intx).Ite m("Instance#" )
objCmd.Paramete rs.Add("@WHNM", SqlDbType.VarCh ar,
20).Value = .Rows(intx).Ite m("WH_NM")
objCmd.Paramete rs.Add("@SCType ", SqlDbType.VarCh ar,
20).Value = cboAuditRpt.Sel ectedItem.Value .Trim
objCmd.Paramete rs.Add("@ProdCo de", SqlDbType.VarCh ar,
20).Value = .Rows(intx).Ite m("Prod_Cd")
objCmd.ExecuteN onQuery()
Next
End With

objConn.Close()
System.Data.Sql Client.SqlExcep tion: Procedure or function
pr_AUDIT_UPLOAD _UpdateStkCntAu d has too many arguments specified.
at System.Data.Sql Client.SqlComma nd.ExecuteReade r(CommandBehavi or
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
at System.Data.Sql Client.SqlComma nd.ExecuteNonQu ery()
Nov 18 '05 #1
2 1538
You keep adding parameters over and over again...call
objCommand.Para meters.Clear() after the ExecuteNonQuery () Although there
are more efficient ways to do it, it should work.

Karl

"Asha" <As**@discussio ns.microsoft.co m> wrote in message
news:CD******** *************** ***********@mic rosoft.com...
greetings, i'm doing a multiple insert into the db through a store proc. i'm very sure the sp has nothing wrong. below are my implementation code and
error msg. thanks in advance for the help

objCmd.Connecti on = objConn
objCmd.CommandT ype = CommandType.Sto redProcedure
objCmd.CommandT ext = "pr_AUDIT_UPLOA D_UpdateStkCntA ud"

With objds.Tables(0)
For intx = 0 To .Rows.Count - 1
objCmd.Paramete rs.Add("@InsId" , SqlDbType.BigIn t).Value = .Rows(intx).Ite m("Instance#" )
objCmd.Paramete rs.Add("@WHNM", SqlDbType.VarCh ar,
20).Value = .Rows(intx).Ite m("WH_NM")
objCmd.Paramete rs.Add("@SCType ", SqlDbType.VarCh ar,
20).Value = cboAuditRpt.Sel ectedItem.Value .Trim
objCmd.Paramete rs.Add("@ProdCo de", SqlDbType.VarCh ar,
20).Value = .Rows(intx).Ite m("Prod_Cd")
objCmd.ExecuteN onQuery()
Next
End With

objConn.Close()
System.Data.Sql Client.SqlExcep tion: Procedure or function
pr_AUDIT_UPLOAD _UpdateStkCntAu d has too many arguments specified.
at System.Data.Sql Client.SqlComma nd.ExecuteReade r(CommandBehavi or
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
at System.Data.Sql Client.SqlComma nd.ExecuteNonQu ery()

Nov 18 '05 #2
After finishing the first row try clearing the parameters collection of the
command object using command.paramet ers.clear()

Hope this helps
Shailesh
MCSD .NET

"Asha" wrote:
greetings, i'm doing a multiple insert into the db through a store proc. i'm
very sure the sp has nothing wrong. below are my implementation code and
error msg. thanks in advance for the help

objCmd.Connecti on = objConn
objCmd.CommandT ype = CommandType.Sto redProcedure
objCmd.CommandT ext = "pr_AUDIT_UPLOA D_UpdateStkCntA ud"

With objds.Tables(0)
For intx = 0 To .Rows.Count - 1
objCmd.Paramete rs.Add("@InsId" , SqlDbType.BigIn t).Value
= .Rows(intx).Ite m("Instance#" )
objCmd.Paramete rs.Add("@WHNM", SqlDbType.VarCh ar,
20).Value = .Rows(intx).Ite m("WH_NM")
objCmd.Paramete rs.Add("@SCType ", SqlDbType.VarCh ar,
20).Value = cboAuditRpt.Sel ectedItem.Value .Trim
objCmd.Paramete rs.Add("@ProdCo de", SqlDbType.VarCh ar,
20).Value = .Rows(intx).Ite m("Prod_Cd")
objCmd.ExecuteN onQuery()
Next
End With

objConn.Close()
System.Data.Sql Client.SqlExcep tion: Procedure or function
pr_AUDIT_UPLOAD _UpdateStkCntAu d has too many arguments specified.
at System.Data.Sql Client.SqlComma nd.ExecuteReade r(CommandBehavi or
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
at System.Data.Sql Client.SqlComma nd.ExecuteNonQu ery()

Nov 18 '05 #3

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

Similar topics

7
33313
by: RotterdamStudents | last post by:
Hello there, i have a strange problem. I can't get php to insert multiple rows at once in a MySQL database. I use the $sql = "INSERT INTO database (a,b,c,d,e) VALUES ('$a', '$b' ,'$c', '$d', '$e')"; I want to insert 5 rows at a time in the database, but it only inserts every 5th record. For example: 1. AA
3
13224
by: jason | last post by:
How does one loop through the contents of a form complicated by dynamic construction of checkboxes which are assigned a 'model' and 'listingID' to the NAME field on the fly in this syntax: Hunter_69. Here is what the form looks like. I have the difficulty of inserting the multiple items selected by the user the first time he visits and uses the screen and then using an UPDATE when he visits later. Model | Original Price | Reduced Price...
10
3230
by: shank | last post by:
I have a recordset that contains multiple records of product a user is purchasing. For clarity, I converted the recordset fields to variables. I need to take that entire recordset and insert it into another table on a remote server. The below code only inserts 1 record. How do I change the code to get all records inserted? thanks! <% Dim DataConn2 Set DataConn2 = Server.CreateObject("ADODB.Connection")
2
2668
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. I've been having some problems with database performance... Several threads are constantly attempting INSERTs of new records into a large table - that is hundreds of thousands of records -large by my account :-) The table has a VARCHAR field...
1
2551
by: John Smith | last post by:
I have a user assigned multiple roles and a role can be inherited from multiple parents (see below). How do I answer such questions as "How many roles does the user belongs to?" I answered the above questions by using .NET but I think it can be more efficient by using just SQL. I would appreciate if you can give me an answer. Thank you.
3
6113
by: DarthMacgyver | last post by:
Hello, I recently wrote a survey application. Each question is very similar. The first questions gives me a problem when there are multiple people taking the survey (The Database connection Timed out) I am using the Data Access Application Blocks as ASP.NET (using VB.NET) and SQL 2000. In there first question there can be up to 27 answers. So I figured instead of making 27 different trips to the database I woulc just concatenate my...
5
6180
by: Arsen V. | last post by:
Hello, What is the optimal way to insert multiple rows (around 1000) from a web application into a table? The user enters multiple lines into a text box (up to 10,000). The ASP.NET application breaks that data into a string array. Each line is an item of that array. The user clicks Submit.
10
6391
by: ads | last post by:
hi, after binding the dropdownlist to a datasource, ive experience this error "Cannot have multiple items selected in a dropdownlist" after using the code: dropdownlist.items.findbyvalue("value").selected = true I didnt specify any selected item in the dropdownlist during binding to the datasource. I use dropdownlist.clearselection() but still error occurs. I need information on this. Thanks. Ads
2
2937
by: Diego | last post by:
Hi everybody! I'm using DB2 PE v8.2.3 for linux. I've defined a database with the following schema: ANNOTATION(ID,AUTHOR,TEXT) ANNOTATION_BOOK(ANNOTATION_ID,OBJECT_ID) BOOK(ID,AUTHOR,TITLE). Between the book and annotation entities there is a many-to-many
58
8118
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 the parts section an i seem to be having trouble. When i try to insert into the parts section i get the error Invalid character value for cast specification. But not sure what i am doing wrong. Here is what i am using to insert. All the sections...
0
9492
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
9299
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,...
1
9885
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9740
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...
1
7287
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
5175
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...
0
5332
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3832
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
3
2702
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.