?
Solved

Specified cast is not valid tinyint to int

Posted on 2007-03-30
4
Medium Priority
?
2,124 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month12 days, 15 hours left to enroll

777 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