Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
926 views
in Technique[技术] by (71.8m points)

asp.net - Procedure or function "" expects parameter "", which was not supplied

i am new on asp.net with vb.code behind

i am trying get 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()

the error is

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

i already try execute store prosedure

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

and return 0 not empty value.

Thanks in advance!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

try by interchanging the 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 strored procedure, you should declare it in the CommandType

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...