[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 615
  • Last Modified:

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

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
Jennifer Barman
Asked:
Jennifer Barman
  • 2
  • 2
2 Solutions
 
Philip PinnellCommented:
have you tried If patient_id.Text = "" Then                UserMsgBox(Me, "Must Insert Patient ID.")                Exit Sub            End If
0
 
Umar Topia.Net Full Stack DeveloperCommented:
If  String.IsNullOrEmpty(patient_id.Text)
Then                 UserMsgBox(Me, "Must Insert Patient ID.")                
Exit Sub            
End If
0
 
Umar Topia.Net Full Stack DeveloperCommented:
If DBNull.Value == patient_id.Text
Then                 UserMsgBox(Me, "Must Insert Patient ID.")                
Exit Sub            
End If
0
 
Jennifer BarmanAuthor Commented:
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
 
Philip PinnellCommented:
Thanks
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now