By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 1,092 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

Multiple insert.

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.