test for null value in returned datareader column

Hello Experts;

I am trying to test for null values in my datareader after returning a successful query.  Gathering information from other solutions found on this site, I managed to put together the below test.  It is not quite right, however, as I get an error message on run-time.  


If drPhysicalAddress.GetString(drPhysicalAddress.GetOrdinal("AptSuite")).IsNullOrEmpty = True Then
                        txtPhysicalAddressAptSuite.Text = ""
                    Else
                        txtPhysicalAddressAptSuite.Text = drPhysicalAddress.GetString(drPhysicalAddress.GetOrdinal("AptSuite"))
                    End If


error:
Argument not specified for parameter 'value' of 'Public Shared Function IsNullOrEmpty(value As String) As Boolean'.      


Is there a better way to test for null value?  What am I doing wrong?

Any help would be much appreciated.  Thank you in advance for your time.
LVL 2
gwosgoodIT MgrAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gnarCommented:
I think you need to rearrange it:



IsNullOrEmpty(drPhysicalAddress.GetString(drPhysicalAddress.GetOrdinal("AptSuite")))

Open in new window

0
gwosgoodIT MgrAuthor Commented:
gnar:

I made the changes you specified and now it is telling me that IsNullOrEmpty is not declared.  Do you know what I have to import or reference in order to use this function?
0
appariCommented:
try

String.IsNullOrEmpty(drPhysicalAddress.GetString(drPhysicalAddress.GetOrdinal("AptSuite")))
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

gwosgoodIT MgrAuthor Commented:
appari:

Here is the change I made:

If String.IsNullOrEmpty(drPhysicalAddress.GetString(drPhysicalAddress.GetOrdinal("AptSuite"))) = True Then

Now it says the specified cast is not valid.  Any ideas?
0
gnarCommented:
What about:

If String.IsNullOrEmpty(drPhysicalAddress("AptSuite").tostring) = True?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gwosgoodIT MgrAuthor Commented:
shazam!

thanks gnar, that worked for some reason.  

I appreciate everyone's support.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.