Solved

Specified cast is not valid tinyint to int

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 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