Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-09-24
5
Medium Priority
?
605 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 1000 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 1000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

876 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