G
Guest
I am being driven absolutely mad. As part of a generic data access library
that was originally written on top of Oracle's OCI and Pro-C libraries but
that I am now porting to ADO.NET I am trying to write some generic code to
process a DataReader. I am programming with the new C++/CLI and I am using
the GetValues() call to return an array of Object^ refs that I am then trying
to process with a bunch of templated code. I originally attempted to read
back some Oracle Number fields into Int32 variables allocated from the
managed heap, but got back a message telling me that a System.Decimal could
not be cast to an Int32. Fair enough; that's when I realized that Oracle
Numbers are first brought back to the client as Decimal types.
Unfortunately, however, the Decimal type does not have a copy constructor, so
that broke a number of places in my generic code. I have since been trying
to do explicit conversions with specialized template functors, but am being
thwarted at every turn. I am now trying to get these Decimals into
OracleNumber objects, because at least these can be copy constructed and will
play nicely with code I already have in place. I was hoping the following
would work:
template<> struct ABIMConversion<OracleNumber^>
{
OracleNumber^ operator()(Object^ h) { return (OracleNumber^)h ; }
};
This compiles fine, but unfortunately at run time I get the error:bUnable to
cast object of type System.Decimal to type
System.Data.OracleClient.OracleNumber. Okay. Then I tried to a construct an
Oracle Number with the constructor that takes a Decimal parameter:
template<> struct ABIMConversion<OracleNumber^>
{
OracleNumber^ operator()(Decimal^ h) { return OracleNumber(h) ; }
};
This refuses to compile with a (to me, seemingly bizzare) message:
Error 1 error C2664:
'System:ata::OracleClient::OracleNumber::OracleNumber(bool)' : cannot
convert parameter 1 from 'System:ecimal ^' to
'bool' c:\abimdataaccesslibrary\DataBinding.h 1529
THere isn't even documented an OracleNumber constructor that takes a bool,
so I really don't understand what's going on. But I'm giving a presentation
on C++/CLI in a day or two and would really love to have this worked out.
Can anyone explain this to me and suggest a workaround?
Much obliged!
that was originally written on top of Oracle's OCI and Pro-C libraries but
that I am now porting to ADO.NET I am trying to write some generic code to
process a DataReader. I am programming with the new C++/CLI and I am using
the GetValues() call to return an array of Object^ refs that I am then trying
to process with a bunch of templated code. I originally attempted to read
back some Oracle Number fields into Int32 variables allocated from the
managed heap, but got back a message telling me that a System.Decimal could
not be cast to an Int32. Fair enough; that's when I realized that Oracle
Numbers are first brought back to the client as Decimal types.
Unfortunately, however, the Decimal type does not have a copy constructor, so
that broke a number of places in my generic code. I have since been trying
to do explicit conversions with specialized template functors, but am being
thwarted at every turn. I am now trying to get these Decimals into
OracleNumber objects, because at least these can be copy constructed and will
play nicely with code I already have in place. I was hoping the following
would work:
template<> struct ABIMConversion<OracleNumber^>
{
OracleNumber^ operator()(Object^ h) { return (OracleNumber^)h ; }
};
This compiles fine, but unfortunately at run time I get the error:bUnable to
cast object of type System.Decimal to type
System.Data.OracleClient.OracleNumber. Okay. Then I tried to a construct an
Oracle Number with the constructor that takes a Decimal parameter:
template<> struct ABIMConversion<OracleNumber^>
{
OracleNumber^ operator()(Decimal^ h) { return OracleNumber(h) ; }
};
This refuses to compile with a (to me, seemingly bizzare) message:
Error 1 error C2664:
'System:ata::OracleClient::OracleNumber::OracleNumber(bool)' : cannot
convert parameter 1 from 'System:ecimal ^' to
'bool' c:\abimdataaccesslibrary\DataBinding.h 1529
THere isn't even documented an OracleNumber constructor that takes a bool,
so I really don't understand what's going on. But I'm giving a presentation
on C++/CLI in a day or two and would really love to have this worked out.
Can anyone explain this to me and suggest a workaround?
Much obliged!