[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to correctly reference a reader element ?

Posted on 2009-07-05
4
Medium Priority
?
167 Views
Last Modified: 2013-11-07
HI

I have noticed that each time I use reader.IsDBNull("element_name") instead of reader.IsDBNull(10)  doesn´t work.

I got the error "input string not in correct format " with the attached code

Thanks in advace.
If Not reader.IsDBNull("ID_EMPLEADO_FARRERA") Then ' This line triggers the error
                        ' Si es Empleado Farrera
                        tipocliente = CType(reader("ID_EMPLEADO_FARRERA"), String)
                        nombrecliente = CType(reader("NOMBRE_FARRERA"), String)
                    Else
                        'Si es Cliente Externo
                        tipocliente = String.Empty
                        nombrecliente = CType(reader("NOMBRE"), String)
                    End If

Open in new window

0
Comment
Question by:dimensionav
[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
4 Comments
 
LVL 41

Accepted Solution

by:
guru_sami earned 1600 total points
ID: 24780964
because reader.IsDBNull() takes int as an parameter and you are trying to pass string.
0
 

Author Comment

by:dimensionav
ID: 24780978
is any other way to pass the element name ? the idea is just to make my code a little more clear.
Thanks
0
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 400 total points
ID: 24781752
you can do something like this:

tipocliente = Convert.ToString(reader("ID_EMPLEADO_FARRERA"))

if tipoclient is Nothing then
else
end if
0
 
LVL 41

Assisted Solution

by:guru_sami
guru_sami earned 1600 total points
ID: 24781921
Try this:
If Not String.IsNullOrEmpty(reader("ID_EMPLEADO_FARRERA").ToString()) Then
    // your code goes here
End If
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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

649 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