Solved

Specified cast is not valid tinyint to int

Posted on 2007-03-30
4
2,120 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 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