-1

私はこの機能を使用しています:

Private Sub Trigger_sales(HIden As Guid)
        Dim connection As New SqlConnection(connectionString)
        connection.Open()
        Dim Command As New SqlCommand()
        Command.Connection = connection
        Command.CommandType = CommandType.StoredProcedure
        Command.CommandText = "[WebSite].[ValidateWebTran]"
        Command.Parameters.Add("@UidWenTranGUID", SqlDbType.UniqueIdentifier)
        Command.Parameters("@UidWenTranGUID").Value = HIden
        Command.Parameters.Add("@sResultDesc", SqlDbType.VarChar)
        Command.Parameters("@sResultDesc").Direction = ParameterDirection.Output
        Command.ExecuteScalar()
        If (String.IsNullOrEmpty(error_process.text = Command.Parameters("@sResultDesc").Value.ToString)) Then
            complete_sales(HIden)
        End If
    End Sub

このエラーが発生します。

String[1]: Size プロパティのサイズが無効な 0 です。

誰かが私が間違っていることを見ることができますか?

4

2 に答える 2

3

試す:

Command.Parameters.Add("@sResultDesc", SqlDbType.VarChar, 255)

255(パラメーターの型が何であれ置き換えます@sResultDesc。それがMAXuseの場合-1。)

于 2013-01-28T20:13:02.727 に答える
0

私はそれがこの行だと思います:

Command.Parameters.Add("@sResultDesc", SqlDbType.VarChar)

実際に Param の値を設定しているのではなく、次のようになります。

Command.Parameters.Add("@sResultDesc", SqlDbType.VarChar).Value = 'myValue

私が言ったように、これはあなたのストアドプロシージャのどの部分が例外を投げているかからの推測です

于 2013-01-28T19:21:09.503 に答える