Home > Archive > SQL Anywhere database > July 2005 > DataTime problem for stored procedure in ADO.NET









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author DataTime problem for stored procedure in ADO.NET
Ditlef

2005-07-27, 7:24 am

There is a problem for procedures returning DateTime.
Query is OK:
Locked,LockedAt,Lock
edBy
'Y','2005-07-13 13:17:51.996','epn'


Procedure call gives ArgumentOutOfRangeEx
ception.
=> Exception:
Year, Month, and Day parameters describe an
un-representable DateTime.


iAnywhere.Data.AsaClient, version: 8.0.3.5267

Regards
Ditlef

We are now developing next release for VS.NET 2005. Very
interested in a .NET 2.0 version of the ADO.NET suplier. The
current version has some inheritance problems, i.e.
AsaDataAdapter not subclass of DbDataAdapter.
The ASE library fits into the Microsoft Enterprise Library
Data Access framework, ASA does not.

CODE:

Procedure executed:
create procedure DBCreators. SP_Test(@IndexPatien
t
UDT_MAININDEX,@OldLo
cked UDT_ENUM output,@OldLockedAt
UDT_DATETIME output,@OldLockedBy UDT_SHORTSTRING output)
as
begin
declare @ret UDT_INT,
@Locked UDT_ENUM,
@LockedAt UDT_DATETIME,
@LockedBy UDT_SHORTSTRING
select @ret=0
/* Current status of the lock */
select Locked,LockedAt,Lock
edBy from DBCreators.Patient
where IndexPatient = @IndexPatient
select @OldLocked=@Locked
select @OldLockedAt=@Locked
At
select @OldLockedBy=@Locked
By
return @ret
end;


C# code:

cmd = new AsaCommand("SP_Test", conn);
cmd.CommandType = CommandType.StoredProcedure;
AddStoredProcParam(c
md, indexPatient,
ParameterDirection.Input, DbType.Int32); // IndexPatient
AddStoredProcParam(c
md, null, ParameterDirection.Output,
DbType.String); // @OldLocked
AddStoredProcParam(c
md, null, ParameterDirection.Output,
DbType.String); // @OldLockedAt
AddStoredProcParam(c
md, null, ParameterDirection.Output,
DbType.String); // @OldLockedBy
int n = (int)cmd.ExecuteScalar();


private static AsaParameter
AddStoredProcParam(A
saCommand cmd, object value,
ParameterDirection direction, DbType dataType)
{
AsaParameter param = cmd.CreateParameter();
param.Direction = direction;
param.DbType = dataType;
param.Value = value;
cmd.Parameters.Add(param);
return param;
}
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com