Conversion from type 'SqlInt32' to type 'Integer' is not valid

G

Greg Burns

I have a lot of autogenerated code (created from LLBL Gen,
http://www.sd.nl/software/) that looks similiar to this:

Dim _errorCode As SqlInt32
....
_errorCode = New
SqlInt32(CType(cmdToExecute.Parameters.Item("@iErrorCode").Value, Integer))

I am upgrading my project to VS 2005. Now, when this code executes I am
getting a run-time error where I did not before. The value of @iErrorCode
is 0, not null.

System.InvalidCastException occurred
System.InvalidCastException: Conversion from type 'SqlInt32' to type
'Integer' is not valid.

Simple fix seems to be to change the code to this:

_errorCode = CType(cmdToExecute.Parameters.Item("@iErrorCode").Value,
SqlInt32)

What has changed in VB 2005 that is causing this?

Thanks,
Greg
 
F

Frans Bouma [C# MVP]

Greg said:
I have a lot of autogenerated code (created from LLBL Gen,
http://www.sd.nl/software/) that looks similiar to this:

Dim _errorCode As SqlInt32
...
_errorCode = New
SqlInt32(CType(cmdToExecute.Parameters.Item("@iErrorCode").Value,
Integer))

I am upgrading my project to VS 2005. Now, when this code executes I
am getting a run-time error where I did not before. The value of
@iErrorCode is 0, not null.

System.InvalidCastException occurred
System.InvalidCastException: Conversion from type 'SqlInt32' to type
'Integer' is not valid.

Simple fix seems to be to change the code to this:

_errorCode = CType(cmdToExecute.Parameters.Item("@iErrorCode").Value,
SqlInt32)

What has changed in VB 2005 that is causing this?

I've no idea, the main thing what was not possible in vs.net 2003 was
the implicit conversion operator usage by VB.NET between sqlint32 and
integer. In vs.net 2005 this is available in VB.NET, perhaps it invokes
these implicit conversions now.

FB

--
 
G

Greg Burns

Thanks for the input.

Greg

Frans Bouma said:
I've no idea, the main thing what was not possible in vs.net 2003 was
the implicit conversion operator usage by VB.NET between sqlint32 and
integer. In vs.net 2005 this is available in VB.NET, perhaps it invokes
these implicit conversions now.

FB

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top