Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why only one character is returned?
Message
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01544467
Message ID:
01544468
Views:
26
>Hi,
>
>This is a continuation of the thread where I am trying to get the value of OUTPUT parameter when calling a stored procedure. The stored procedure is very simple and has one OUTPUT parameter where the value is set to something like 'ABCD' (I tried, '1234', and so on).
>
>The problem is that the code below, when gets the value of parameter only shows 1 character. E.g. 'A' or '1', and so on.
>
>Here is the summary of the code (basically copy of what Viv suggested in the other thread):
>
> System.Data.Common.DbCommand command = new SqlCommand();
> System.Data.IDbDataParameter p = command.CreateParameter();
> p.ParameterName = "@Param3";
> p.Direction = ParameterDirection.Output;
> p.Value = cVal3;
> command.Parameters.Add(p);
>int RetValue = command.ExecuteNonQuery()
> var v = command.Parameters["@Param3"].Value;
>// the value 'v' has 'A' or '1' but never the entire string
>
>
>Do you see where could be the problem? TIA.

You need to define size of the parameter. Also, is the declaration of this parameter correct in the sp? Can you show how it is declared there?
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform