How to get LongVarchar parameter from SPROC in ADO.NET 2.0 using SQLAnywhere 10?
I have a sproc 'up_selfassessform_view' that has the following parameters:
in ai_eqidentkey SYSKEY
in ai_acidentkey SYSKEY
out as_eqcomments TEXT_STRING
out as_acexplanation TEXT_STRING
- which are domain objects. SYSKEY is "integer" and TEXT_STRING is "long varchar".
I can call sproc fine from iSQL using the following code:
create variable @eqcomments TEXT_STRING;
create variable @acexamples TEXT_STRING;
call up_selfassessform_view (75000146, 3, @eqcomments, @acexamples);
select @eqcomments, @acexamples;
- which returns correct values from DB (so I know SPROC is good).
I configured the out parameter in ADO.NET like this (worked so far for "integer", "timestamp", "varchar (255)", etc.):
SAParameter as_acexplanation = cmd.CreateParameter();
as_acexplanation.Direction = ParameterDirection.Output;
as_acexplanation.ParameterName = "as_acexplanation";
as_acexplanation.SADbType = SADbType.LongVarchar;
cmd.Parameters.Add(as_acexplanation);
When I run the following code:
SADataReader reader = cmd.ExecuteReader();
I am getting the following error:
Parameter[2]: the Size property has an invalid size of 0.
Which (I suppose) makes sense ...
But the point is, I don't know the size of the field (it's just "long varchar" doesn't have a given length - unlike varchar (XXX)).
Anyway, just for fun, I add the following:
as_acexplanation.Size = 1000;
and above the error goes away, but now when I call:
as_acexplanation.Value
i am returning a string of length = 1000, which is just "\ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 \ 0 ... '(\ 0 repeated 1000 times).
So, I'm really stuck ... Any help one of these would be much appreciated.
Hooray!;)
Tod T.