J
jason
hello everyone. i am using ADODB in a C# class library. why? because
one of the applications using the class library is written in classic
ASP, and therefore can't be handed an ADO.NET DataReader class and know
what to do with it.
no problem, ADODB in C# lets me generate a class RecordSet object to
hand to the ASP classic application without trouble in most cases.
however, this is one of the problem cases:
i originally had the following code in a C# method:
// INT VERSION
// AuthorityID was a public int property
// nUserID was an argument supplied in the method call
oCommand.Parameters.Append(
oCommand.CreateParameter("@authorityid",
ADODB.DataTypeEnum.adInteger,
ADODB.ParameterDirectionEnum.adParamInput,
System.Runtime.InteropServices.Marshal.SizeOf(AuthorityID),
AuthorityID));
oCommand.Parameters.Append(
oCommand.CreateParameter("@userid", ADODB.DataTypeEnum.adInteger,
ADODB.ParameterDirectionEnum.adParamInput,
System.Runtime.InteropServices.Marshal.SizeOf(nUserID),
nUserID));
this code worked fine, and generated the desired recordset when
executed. however, the datatype of the column (and therefore the stored
procedure parameter) changed from an int to a guid. this meant the
following code change:
// GUID VERSION
Guid gUserID = new Guid(sUserID);
Guid gAuthorityID = new Guid(AuthorityID);
oCommand.Parameters.Append(
oCommand.CreateParameter("@authorityid",
ADODB.DataTypeEnum.adGUID,
ADODB.ParameterDirectionEnum.adParamInput,
System.Runtime.InteropServices.Marshal.SizeOf(gAuthorityID),
gAuthorityID));
oCommand.Parameters.Append(
oCommand.CreateParameter("@userid", ADODB.DataTypeEnum.adGUID,
ADODB.ParameterDirectionEnum.adParamInput,
System.Runtime.InteropServices.Marshal.SizeOf(gUserID),
gUserID));
the old code worked just fine, but the new code generates a Stack
Overflow error. i tried putting the two methods in a try / catch block,
but it failed to cause an actual exception, so I'm not sure what
exactly is causing the overflow in the GUID version. Any ideas? Is it
that .NET GUID class doesn't play well with the ADO objects?
i've tried different sizes for the guid parameters as well. such as the
static 16 bytes that a guid should be. a whopping 200 bytes just to
make sure it wasn't too small. zero bytes to see if that would cause
ADODB to auto-size. all of these things generated the overflow.
any help would be greatly appreciated!
jason
Any help is appreciated,
one of the applications using the class library is written in classic
ASP, and therefore can't be handed an ADO.NET DataReader class and know
what to do with it.
no problem, ADODB in C# lets me generate a class RecordSet object to
hand to the ASP classic application without trouble in most cases.
however, this is one of the problem cases:
i originally had the following code in a C# method:
// INT VERSION
// AuthorityID was a public int property
// nUserID was an argument supplied in the method call
oCommand.Parameters.Append(
oCommand.CreateParameter("@authorityid",
ADODB.DataTypeEnum.adInteger,
ADODB.ParameterDirectionEnum.adParamInput,
System.Runtime.InteropServices.Marshal.SizeOf(AuthorityID),
AuthorityID));
oCommand.Parameters.Append(
oCommand.CreateParameter("@userid", ADODB.DataTypeEnum.adInteger,
ADODB.ParameterDirectionEnum.adParamInput,
System.Runtime.InteropServices.Marshal.SizeOf(nUserID),
nUserID));
this code worked fine, and generated the desired recordset when
executed. however, the datatype of the column (and therefore the stored
procedure parameter) changed from an int to a guid. this meant the
following code change:
// GUID VERSION
Guid gUserID = new Guid(sUserID);
Guid gAuthorityID = new Guid(AuthorityID);
oCommand.Parameters.Append(
oCommand.CreateParameter("@authorityid",
ADODB.DataTypeEnum.adGUID,
ADODB.ParameterDirectionEnum.adParamInput,
System.Runtime.InteropServices.Marshal.SizeOf(gAuthorityID),
gAuthorityID));
oCommand.Parameters.Append(
oCommand.CreateParameter("@userid", ADODB.DataTypeEnum.adGUID,
ADODB.ParameterDirectionEnum.adParamInput,
System.Runtime.InteropServices.Marshal.SizeOf(gUserID),
gUserID));
the old code worked just fine, but the new code generates a Stack
Overflow error. i tried putting the two methods in a try / catch block,
but it failed to cause an actual exception, so I'm not sure what
exactly is causing the overflow in the GUID version. Any ideas? Is it
that .NET GUID class doesn't play well with the ADO objects?
i've tried different sizes for the guid parameters as well. such as the
static 16 bytes that a guid should be. a whopping 200 bytes just to
make sure it wasn't too small. zero bytes to see if that would cause
ADODB to auto-size. all of these things generated the overflow.
any help would be greatly appreciated!
jason
Any help is appreciated,