473,804 Members | 3,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

check if field is empty/nothing/null????

cj2
if myodbcreader.ha srows then
if myodbcreader("c ode").trim = "" or myodbcreader("r eas").trim = "aVAL"
then
do something
endif
endif

Is this the appropriate way to test if the code field is something other
an a value? I find I can also say if myodbcreader("c ode").trim = nothing.

What about or vs orelse? I've heard I should use orelse yet I don't
know why.
Nov 21 '08 #1
3 6710
On Nov 21, 2:43*pm, cj2 <c...@nospam.no spamwrote:
if myodbcreader.ha srows then
* * * * if myodbcreader("c ode").trim = "" or myodbcreader("r eas").trim = "aVAL"
then
* * * * * * * * do something
* * * * endif
endif

Is this the appropriate way to test if the code field is something other
an a value? *I find I can also say if myodbcreader("c ode").trim = nothing.

What about or vs orelse? *I've heard I should use orelse yet I don't
know why.
Orelse means that if the first condition is true, then don't bother to
check the next condition.

Best way to check to see if a column in an ODBCDataReader is null is
to use the IsDBNull method.
Nov 21 '08 #2
cj2
isdbnull reports false when the field is = "" or " ". What I was
trying to say when I said "when a field is something other than a value"
was I don't consider "" or " " a value.
za***@construct ion-imaging.com wrote:
On Nov 21, 2:43 pm, cj2 <c...@nospam.no spamwrote:
>if myodbcreader.ha srows then
if myodbcreader("c ode").trim = "" or myodbcreader("r eas").trim = "aVAL"
then
do something
endif
endif

Is this the appropriate way to test if the code field is something other
an a value? I find I can also say if myodbcreader("c ode").trim = nothing.

What about or vs orelse? I've heard I should use orelse yet I don't
know why.

Orelse means that if the first condition is true, then don't bother to
check the next condition.

Best way to check to see if a column in an ODBCDataReader is null is
to use the IsDBNull method.
Nov 21 '08 #3
You've got a number of choices about how to deal with this issue.

The first thing to do is investigate the methods exposed by the
OdbcDataReader class.

The IsDBNull and GetString methods jump out immediately and used in
conjunction with the String.Trim and String.IsNullOr Empty methods you should
be able to develop a very robust handler.
"cj2" <cj*@nospam.nos pamwrote in message
news:OL******** ******@TK2MSFTN GP02.phx.gbl...
isdbnull reports false when the field is = "" or " ". What I was trying
to say when I said "when a field is something other than a value" was I
don't consider "" or " " a value.
za***@construct ion-imaging.com wrote:
>On Nov 21, 2:43 pm, cj2 <c...@nospam.no spamwrote:
>>if myodbcreader.ha srows then
if myodbcreader("c ode").trim = "" or myodbcreader("r eas").trim =
"aVAL"
then
do something
endif
endif

Is this the appropriate way to test if the code field is something other
an a value? I find I can also say if myodbcreader("c ode").trim =
nothing.

What about or vs orelse? I've heard I should use orelse yet I don't
know why.

Orelse means that if the first condition is true, then don't bother to
check the next condition.

Best way to check to see if a column in an ODBCDataReader is null is
to use the IsDBNull method.
Nov 21 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5715
by: ratlhead | last post by:
Hey all, I've provided a form for a client of the company I work for that basically emails the form data to an email address. Only a couple of the many fields are required...nothing too fancy. However, the sys admin has made the following request: "All fields, not just the required fields, need validation for syntax, shell escape characters and string length. This is a security issue."
6
15466
by: pam | last post by:
sorry for my poor english first. $notation=$rs->fields; if(!empty($notation)) echo $notation; the notation field in database is a text type, when the value is null, it will cause a mistake; i used empty function to check it, but it seems don't take effect.
2
41405
by: Paul Telco | last post by:
Hello, I'm a new user designing a simple database to retrieve pre-prepared docunents for printing. I have five tables, a form to design the documents, a form to customise and retrieve the documents, a query to pull the data together from the tables and a report which formats the document with the custom data ready to print. It works very well unless:
1
1949
by: GGerard | last post by:
Hello I am working with Access 2000 I have two tables joined on a one to many relationship between two fields: Table1:FieldID (one) is joined to Table2:FieldMyID (many) Field Properties setting: FieldID : Field Size - Long Integer New Values - Increment
5
24641
by: Krechting | last post by:
Hi ALl, I have a code that checks if the documents in a hyperlink field are still where they should be. I use fileexist(). First I want to filter out all the hyperlink fields that are empty. I open a recordset and browse through all the fields to check for the word file. I cannot filter out the empty fields. I have tried: If Len(.Fields("Link") <> 0 then and: If Not IsNull(.Fields("Link")) then
5
10838
by: Shapper | last post by:
Hello, I am using this code line to check i a variable exists: If cookie Is Nothing Then .... How can I check if cookie is empty when cookie exists? Thanks, Miguel
7
15994
by: Alan Johnson | last post by:
It seems useful to be able to distinguish between an empty weak_ptr and one that has merely expired. For example: void f(weak_ptr<T> wp) { if (/* wp is empty */) { // Act is if a NULL pointer was passed. } else
26
3815
by: Neville Lang | last post by:
Hi all, I am having a memory blank at the moment. I have been writing in C# for a number of years and now need to do something in VB.NET, so forgive me such a primitive question. In C#, I test whether a string has a value or not by the following syntax: if (thisString.Trim() == "") {
2
8830
by: Bart | last post by:
Hi, i need to check wether a cell of a gridview is empty or not. I did this: Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged Dim log1 As String log1 = GridView1.SelectedRow.Cells(1).Text .....
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10580
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10335
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9157
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7621
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5652
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2993
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.