Solved

Specified cast is not valid tinyint to int

Posted on 2007-03-30
4
2,112 Views
Last Modified: 2011-09-20
myobj.Intproperty = myReader.GetInt32(myDataRecord.GetOrdinal("tinyintfield"))

Intproperty is a property in a class and its datatype is int
tinyintfield is a field in the table and its datatype is tinyint

Error message : - Specified cast is not valid.

Any thoughts
0
Comment
Question by:PradeepYadhav
  • 2
  • 2
4 Comments
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 18822231
myReader[myDataRecord.GetOrdinal("tinyintfield")].ToString() and see what the data is maybe a null value or something
0
 

Author Comment

by:PradeepYadhav
ID: 18822250
No they dont contain null.
0
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 500 total points
ID: 18822261
what does this give

myReader[myDataRecord.GetOrdinal("tinyintfield")].ToString()
0
 

Author Comment

by:PradeepYadhav
ID: 18822262
if i convert it to int in the stored proc then it works fine.

select convert (int,tinyintfield) from table
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now