Multiple insert.

G

Guest

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(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
 
G

Guest

After finishing the first row try clearing the parameters collection of the
command object using command.parameters.clear()

Hope this helps
Shailesh
MCSD .NET
 
K

Karl

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top