Procedure or function "expects parameter" "which was not set

I am new to asp.net with vb.code for

I am trying to get the value from sql

my code

Dim apps As New MyApps apps.OpenConnection() Dim esql As New SqlCommand esql.Connection = apps.oConn esql.CommandText = "cekdatauploads" esql.Parameters.Add("@value", SqlDbType.Int, 2) esql.ExecuteNonQuery() esql.Parameters("@value").Direction = ParameterDirection.Output Dim nilai As Integer = esql.Parameters("@value").Value apps.CloseConnection() 

error

 The parameterized query '(@value int)cekdatauploads' expects the parameter '@value', which was not supplied. 

I'm already trying to break through the store

 declare @p int exec [cekdatauploads] @p output print @p 

and return 0 is not an empty value.

Thanks in advance!

+4
source share
2 answers

try replacing two lines.

 esql.CommandText = "cekdatauploads" esql.Parameters.Add("@value", SqlDbType.Int, 2) esql.Parameters("@value").Direction = ParameterDirection.Output esql.ExecuteNonQuery() 

one more thing if cekdatauploads is a complicated procedure, you have to declare it in CommandType

 esql.CommandType = CommandType.StoredProcedure esql.CommandText = "cekdatauploads" esql.Parameters.Add("@value", SqlDbType.Int, 2) esql.Parameters("@value").Direction = ParameterDirection.Output esql.ExecuteNonQuery() 
+7
source

You perform this procedure before telling the command that it is an output parameter, by default it assumes that it is an input parameter .:

 esql.Parameters("@value").Direction = ParameterDirection.Output esql.ExecuteNonQuery() 
+3
source

All Articles