Solved

IF THEN statement IF NULL in ASP.NET Visual studio 2008

Posted on 2010-09-24
5
597 Views
Last Modified: 2012-05-10
I would think this would be an easy answer, but I have not been able to resolve this for a few hours now... What I need is to create an if then statement saying if this textbox is null then do this: ..... I can't seem to code the correct statement for this to work.. It is happening on a button click. When they click on the UPDATE button in my app... I need it to look at the data that is being passed into my database and if it is NULL then I need it to pop up an alert box. Now I have the programming correct for the alert box. I tested it to where I put in a IF = "cat" then do... and it popped the box right up.. but now when I am trying to tell it to look if it is null it is not working.. Here is the code that I am working on...
If IsDBNull(patient_id.Text) Then
                UserMsgBox(Me, "Must Insert Patient ID.")
                Exit Sub
            End If

Open in new window

0
Comment
Question by:Jennifer Barman
  • 2
  • 2
5 Comments
 
LVL 13

Accepted Solution

by:
Philip Pinnell earned 250 total points
ID: 33754240
have you tried If patient_id.Text = "" Then                UserMsgBox(Me, "Must Insert Patient ID.")                Exit Sub            End If
0
 
LVL 10

Assisted Solution

by:Umar Topia
Umar Topia earned 250 total points
ID: 33754281
If  String.IsNullOrEmpty(patient_id.Text)
Then                 UserMsgBox(Me, "Must Insert Patient ID.")                
Exit Sub            
End If
0
 
LVL 10

Expert Comment

by:Umar Topia
ID: 33754298
If DBNull.Value == patient_id.Text
Then                 UserMsgBox(Me, "Must Insert Patient ID.")                
Exit Sub            
End If
0
 

Author Closing Comment

by:Jennifer Barman
ID: 33754327
Both of these worked!!! :) I knew it was easy!! I tried the first one suggested before, but I think I had my statement in the wrong place!! THANKS FOR ALL ASSISTANCE!! LIFE SAVER!! :) :)
0
 
LVL 13

Expert Comment

by:Philip Pinnell
ID: 33754338
Thanks
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

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.

679 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