Solved

Conversion e.keys from type 'DBNull' to type 'Integer' is not valid on e.keys(0)

Posted on 2013-02-07
2
341 Views
Last Modified: 2013-02-07
Hi,

I am getting the following error when the selectedID is Nothing, how can I fix that?

Conversion e.keys from type 'DBNull' to type 'Integer' is not valid.
0
Comment
Question by:JessyRobinson1234
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 275 total points
ID: 38863139
you have FIRST to check of the value is DBNull.Value before trying to convert it.
or make sure the value is not dbnull.value in the first place, but always a "integer" value.

if ( e.keys(0) != DBNull.Value) 
{
  // do the cast as needed
}
else
{
  // value is null... what to do here?
} 

Open in new window

0
 
LVL 42

Expert Comment

by:sedgwick
ID: 38863146
simply check selectedID for DB.Null before assign to your integer variable
if IsDBNull(selectedID ) then
''do something 
end if

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

896 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

19 Experts available now in Live!

Get 1:1 Help Now