PC Review


Reply
Thread Tools Rate Thread

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

 
 
Greg Burns
Guest
Posts: n/a
 
      31st Oct 2005
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


 
Reply With Quote
 
 
 
 
Frans Bouma [C# MVP]
Guest
Posts: n/a
 
      31st Oct 2005
Greg Burns wrote:

> 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

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 
Reply With Quote
 
Greg Burns
Guest
Posts: n/a
 
      31st Oct 2005
Thanks for the input.

Greg

"Frans Bouma [C# MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Greg Burns wrote:
>
>> 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
>
> --
> ------------------------------------------------------------------------
> Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
> My .NET blog: http://weblogs.asp.net/fbouma
> Microsoft MVP (C#)
> ------------------------------------------------------------------------



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conversion from type 'DBNull' to type 'String' is not valid Cirene Microsoft ASP .NET 2 19th Jun 2008 06:18 AM
Conversion from string "" to type 'Integer' is not valid. Dave griffiths Microsoft VB .NET 10 2nd Jul 2007 06:20 PM
Conversion from string "0" to type 'Integer' is not valid =?Utf-8?B?U0ZyeQ==?= Microsoft Dot NET Framework 6 9th Feb 2007 07:21 AM
Conversion from type 'DBNull' to type 'String' is not valid Chris Microsoft ASP .NET 2 11th May 2006 09:20 AM
Cast from type 'Field' to type 'Integer' is not valid William Mild Microsoft VB .NET 3 28th Aug 2003 09:00 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:32 AM.