473,326 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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

Jun 6 '06 #1
5 1735
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

Jun 6 '06 #2

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

Jun 6 '06 #3
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

Jun 6 '06 #4
You can test if the field is equal to System.DBNull.Value first. Or I think
Convert.ToString() might handle DBNull.

"amjad" <am***@discussions.microsoft.com> wrote in message
news:3F**********************************@microsof t.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

Jun 6 '06 #5
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

Jun 7 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: techy techno | last post by:
Hii I am trying to write down a cdont aplication which will email the survey form to the TO address with the answers checked by the user using the survey form I am 100% sure that there is...
5
by: VbUser25 | last post by:
hi i need urgent responses.. i have some 15 checkboxex on a form... i want to 1st check the no. of checkboxes that are checked?? and then loop it that many times adn insert the quantities the...
4
by: Nick | last post by:
Hi I am a little stuck. I have a web app which uses cookieless session management. I would like to inform a user when their session has ended but cannot work out how to implement. I thought...
1
by: sathya | last post by:
hi, i have problem in httphandler, my problem is that when i am trying to use server.execute(/default.aspx) i am getting error.... Here i am trying to redirect from home.aspx to...
8
by: Tim::.. | last post by:
Can someone please tell me why I keep getting the following error for some of my web application users but not others??? Even though the application runs from a central webserver??? Thanks for...
16
by: | last post by:
Hi all, I have a website running on beta 2.0 on server 2003 web sp1 and I keep getting the following error:- Error In:...
1
by: SpiderSwamy | last post by:
Hi, I know little bit about asp, I am facing a problem in Validating the ASP Form.. Example: Stud ID: 501242016 FirstName: Ajit LastName: Kar
0
by: Nehad9 | last post by:
Hi, I am moving an existing ASP application from Win 2k3, IIS 6.0 to a new Win2k3 IIS 6.0 but the same pice of code that works on the old machine give a "blank" page on new machine. On debugging,...
5
by: oliharvey | last post by:
hallo - I am making a web request (actually a web service call) from within my web service. this works fine under the developement web server - but fails under IIS with: anyone have any...
0
by: fireline1082 | last post by:
Hi every body I am doing a project in which I have a Windows Certificate Authority server and RADIUS server (IAS RADIUS server under windows ) . In this project the clients will login to the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.