我是asp.net的新手,后面是vb.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 parameterized query '(@value int)cekdatauploads' expects the parameter '@value',which was not supplied.
我已经尝试执行商店prosedure了
declare @p int exec [cekdatauploads] @p output print @p
并返回0而不是空值.
提前致谢!
解决方法
尝试通过互换两条线.
esql.CommandText = "cekdatauploads" esql.Parameters.Add("@value",2) esql.Parameters("@value").Direction = ParameterDirection.Output esql.ExecuteNonQuery()
还有一件事,如果cekdatauploads是一个标记过程,你应该在CommandType中声明它
esql.CommandType = CommandType.StoredProcedure esql.CommandText = "cekdatauploads" esql.Parameters.Add("@value",2) esql.Parameters("@value").Direction = ParameterDirection.Output esql.ExecuteNonQuery()