asp.net urgent request

Discussion in 'ASP .Net' started by =?Utf-8?B?YW1qYWQ=?=, Jun 6, 2006.

  1. 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=?=, Jun 6, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?YW1qYWQ=?=

    Ray Booysen Guest

    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
    >
     
    Ray Booysen, Jun 6, 2006
    #2
    1. Advertising

  3. 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=?=, Jun 6, 2006
    #3
  4. 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=?=, Jun 6, 2006
    #4
  5. You can test if the field is equal to System.DBNull.Value first. Or I think
    Convert.ToString() might handle DBNull.

    "amjad" <> wrote in message
    news:...
    >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, Jun 6, 2006
    #5
  6. 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
    >
     
    =?Utf-8?B?YW1qYWQ=?=, Jun 7, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Birtle
    Replies:
    2
    Views:
    2,070
    John Saunders
    Oct 16, 2003
  2. =?Utf-8?B?ZXN3YW5zb24=?=

    asp.net form to send a request to a put request

    =?Utf-8?B?ZXN3YW5zb24=?=, Oct 29, 2004, in forum: ASP .Net
    Replies:
    9
    Views:
    607
    =?Utf-8?B?ZWpz?=
    Nov 9, 2004
  3. Sachin Jagtap

    URGENT !! QUEUE STL PROBLEM URGENT!!

    Sachin Jagtap, Apr 28, 2005, in forum: C++
    Replies:
    4
    Views:
    1,047
    Mark Stijnman
    Apr 29, 2005
  4. Rob
    Replies:
    3
    Views:
    443
  5. Replies:
    1
    Views:
    270
Loading...

Share This Page