Solved

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

Posted on 2010-09-24
5
588 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

707 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now