Solved

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

Posted on 2013-02-07
2
342 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

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…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

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