473,324 Members | 2,196 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,324 software developers and data experts.

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.Connection = objConn
objCmd.CommandType = CommandType.StoredProcedure
objCmd.CommandText = "pr_AUDIT_UPLOAD_UpdateStkCntAud"

With objds.Tables(0)
For intx = 0 To .Rows.Count - 1
objCmd.Parameters.Add("@InsId", SqlDbType.BigInt).Value
= .Rows(intx).Item("Instance#")
objCmd.Parameters.Add("@WHNM", SqlDbType.VarChar,
20).Value = .Rows(intx).Item("WH_NM")
objCmd.Parameters.Add("@SCType", SqlDbType.VarChar,
20).Value = cboAuditRpt.SelectedItem.Value.Trim
objCmd.Parameters.Add("@ProdCode", SqlDbType.VarChar,
20).Value = .Rows(intx).Item("Prod_Cd")
objCmd.ExecuteNonQuery()
Next
End With

objConn.Close()
System.Data.SqlClient.SqlException: Procedure or function
pr_AUDIT_UPLOAD_UpdateStkCntAud has too many arguments specified.
at System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
Nov 18 '05 #1
2 1510
You keep adding parameters over and over again...call
objCommand.Parameters.Clear() after the ExecuteNonQuery() Although there
are more efficient ways to do it, it should work.

Karl

"Asha" <As**@discussions.microsoft.com> wrote in message
news:CD**********************************@microsof t.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.Connection = objConn
objCmd.CommandType = CommandType.StoredProcedure
objCmd.CommandText = "pr_AUDIT_UPLOAD_UpdateStkCntAud"

With objds.Tables(0)
For intx = 0 To .Rows.Count - 1
objCmd.Parameters.Add("@InsId", SqlDbType.BigInt).Value = .Rows(intx).Item("Instance#")
objCmd.Parameters.Add("@WHNM", SqlDbType.VarChar,
20).Value = .Rows(intx).Item("WH_NM")
objCmd.Parameters.Add("@SCType", SqlDbType.VarChar,
20).Value = cboAuditRpt.SelectedItem.Value.Trim
objCmd.Parameters.Add("@ProdCode", SqlDbType.VarChar,
20).Value = .Rows(intx).Item("Prod_Cd")
objCmd.ExecuteNonQuery()
Next
End With

objConn.Close()
System.Data.SqlClient.SqlException: Procedure or function
pr_AUDIT_UPLOAD_UpdateStkCntAud has too many arguments specified.
at System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()

Nov 18 '05 #2
After finishing the first row try clearing the parameters collection of the
command object using command.parameters.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.Connection = objConn
objCmd.CommandType = CommandType.StoredProcedure
objCmd.CommandText = "pr_AUDIT_UPLOAD_UpdateStkCntAud"

With objds.Tables(0)
For intx = 0 To .Rows.Count - 1
objCmd.Parameters.Add("@InsId", SqlDbType.BigInt).Value
= .Rows(intx).Item("Instance#")
objCmd.Parameters.Add("@WHNM", SqlDbType.VarChar,
20).Value = .Rows(intx).Item("WH_NM")
objCmd.Parameters.Add("@SCType", SqlDbType.VarChar,
20).Value = cboAuditRpt.SelectedItem.Value.Trim
objCmd.Parameters.Add("@ProdCode", SqlDbType.VarChar,
20).Value = .Rows(intx).Item("Prod_Cd")
objCmd.ExecuteNonQuery()
Next
End With

objConn.Close()
System.Data.SqlClient.SqlException: Procedure or function
pr_AUDIT_UPLOAD_UpdateStkCntAud has too many arguments specified.
at System.Data.SqlClient.SqlCommand.ExecuteReader(Com mandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()

Nov 18 '05 #3

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

Similar topics

7
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',...
3
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:...
10
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...
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....
1
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...
3
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...
5
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...
10
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:...
2
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)...
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
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.