Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   asp.net urgent request (http://www.velocityreviews.com/forums/t297516-asp-net-urgent-request.html)

=?Utf-8?B?YW1qYWQ=?= 06-06-2006 02:39 PM

asp.net urgent request
 
System.InvalidCastException: Unable to cast object of type 'System.Byte' to
type 'System.String'.

i am using sql serve 2005 and asp.net 1.1
i dont know why i am getting that error i am not uisng any byte type i have
three type of data in sql varcha datetime and tinyint....
any body have any idea how to reslove that problem as i am uisng sqlreader
to read the data and save it in local variables. thanks


Ray Booysen 06-06-2006 02:51 PM

Re: asp.net urgent request
 
Hi amjad

Would it be possible to post some code?

amjad wrote:
> System.InvalidCastException: Unable to cast object of type 'System.Byte' to
> type 'System.String'.
>
> i am using sql serve 2005 and asp.net 1.1
> i dont know why i am getting that error i am not uisng any byte type i have
> three type of data in sql varcha datetime and tinyint....
> any body have any idea how to reslove that problem as i am uisng sqlreader
> to read the data and save it in local variables. thanks
>


=?Utf-8?B?YW1qYWQ=?= 06-06-2006 03:05 PM

Re: asp.net urgent request
 

if(reader.Read())
{
result = new Customer((string)reader["CustID"], (DateTime)reader["BirthDate"],
(string)reader["Name"], (string)reader["Sex"],
(short)reader["NameFormatCode"]);

}

"Ray Booysen" wrote:

> Hi amjad
>
> Would it be possible to post some code?
>
> amjad wrote:
> > System.InvalidCastException: Unable to cast object of type 'System.Byte' to
> > type 'System.String'.
> >
> > i am using sql serve 2005 and asp.net 1.1
> > i dont know why i am getting that error i am not uisng any byte type i have
> > three type of data in sql varcha datetime and tinyint....
> > any body have any idea how to reslove that problem as i am uisng sqlreader
> > to read the data and save it in local variables. thanks
> >

>


=?Utf-8?B?YW1qYWQ=?= 06-06-2006 04:00 PM

RE: asp.net urgent request
 
I have solved that problem but another problem now i am facing is that DBNULL
cannot convert to string .. i am assuming some field values are null ... do
you have any idea to how to convert even if it has null value also thanks

"amjad" wrote:

> System.InvalidCastException: Unable to cast object of type 'System.Byte' to
> type 'System.String'.
>
> i am using sql serve 2005 and asp.net 1.1
> i dont know why i am getting that error i am not uisng any byte type i have
> three type of data in sql varcha datetime and tinyint....
> any body have any idea how to reslove that problem as i am uisng sqlreader
> to read the data and save it in local variables. thanks
>


Benjamin Strackany 06-06-2006 05:58 PM

Re: asp.net urgent request
 
You can test if the field is equal to System.DBNull.Value first. Or I think
Convert.ToString() might handle DBNull.

"amjad" <amjad@discussions.microsoft.com> wrote in message
news:3FD8EF7E-D596-459B-AE42-5264D0DBD04E@microsoft.com...
>I have solved that problem but another problem now i am facing is that
>DBNULL
> cannot convert to string .. i am assuming some field values are null ...
> do
> you have any idea to how to convert even if it has null value also thanks
>
> "amjad" wrote:
>
>> System.InvalidCastException: Unable to cast object of type 'System.Byte'
>> to
>> type 'System.String'.
>>
>> i am using sql serve 2005 and asp.net 1.1
>> i dont know why i am getting that error i am not uisng any byte type i
>> have
>> three type of data in sql varcha datetime and tinyint....
>> any body have any idea how to reslove that problem as i am uisng
>> sqlreader
>> to read the data and save it in local variables. thanks
>>




=?Utf-8?B?YW1qYWQ=?= 06-07-2006 08:26 AM

RE: asp.net urgent request
 
Yeah theoritically it should hand dbnull but i dont know with asp.net its not
doing that if any field contain dbnull data it gave me exception ..... its
bit headache any one know better way to do that thing . thanks

"amjad" wrote:

> System.InvalidCastException: Unable to cast object of type 'System.Byte' to
> type 'System.String'.
>
> i am using sql serve 2005 and asp.net 1.1
> i dont know why i am getting that error i am not uisng any byte type i have
> three type of data in sql varcha datetime and tinyint....
> any body have any idea how to reslove that problem as i am uisng sqlreader
> to read the data and save it in local variables. thanks
>



All times are GMT. The time now is 07:57 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.