Click here to Skip to main content
16,012,468 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Can you please tell me whats wrong
Fails saying
"Procedure or function 'sp_SetDestinations' expects parameter '@Sex', which was not supplied."

my stored procedure "sp_SetDestinations" works when executed in MSSMS

VB
Using cn As New SqlConnection(ConnStr), cmd As New SqlCommand("sp_SetDestinations", cn)
cn.Open()
cmd.Parameters.Add("@Sex", SqlDbType.Char).Value = DR1("Sex").ToString
cmd.Parameters.Add("@Breed", SqlDbType.Char).Value = DR1("Breed").ToString
cmd.Parameters.Add("@FQA", SqlDbType.Char).Value = gFQA
cmd.Parameters.Add("@Moves", SqlDbType.Int).Value = DR1("Moves")
cmd.Parameters.Add("@Months", SqlDbType.Int).Value = DR1("Months")
gStr1 = cmd.ExecuteScalar().ToString
 
End Using


Thanks
Posted
Updated 29-May-14 3:32am
v2
Comments
[no name] 29-May-14 9:20am    
You need to set the command type to stored procedure.
PIEBALDconsult 29-May-14 9:35am    
Possibly the value of DR1("Sex").ToString is NULL ? If so, you need to replace it with DBNull.Value.

1 solution

Hello ,
put CommandType by this way
cmd.CommandType = CommandType.StoredProcedure

thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900