4

私はasp.netで新しいですが、vb.codeが背後にあります

私はSQLから値を取得しようとしています

私のコード

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.

私はすでにストア手順を実行しようとしています

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

空ではなく0の値を返します。

前もって感謝します!

4

2 に答える 2

7

2本の線を入れ替えてみてください。

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

もう1つ、もしそれcekdatauploadsがストローされた手順であるなら、あなたはそれをで宣言するべきですCommandType

esql.CommandType = CommandType.StoredProcedure
esql.CommandText = "cekdatauploads"
esql.Parameters.Add("@value", SqlDbType.Int, 2)
esql.Parameters("@value").Direction = ParameterDirection.Output
esql.ExecuteNonQuery()
于 2013-02-08T12:15:32.227 に答える
3

コマンドに出力パラメーターであることを通知する前に、プロシージャーを実行しています。デフォルトでは、それは入力パラメーターであると想定しています。

esql.Parameters("@value").Direction = ParameterDirection.Output
esql.ExecuteNonQuery()
于 2013-02-08T12:16:14.673 に答える