If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > empty value of ms access, asp, vbscript

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-17-07, 11:43
Dilruba Dilruba is offline
Registered User
 
Join Date: Nov 2007
Posts: 7
empty value of ms access, asp, vbscript

How we can recognize an empty value of ms access field.


suppose :

Code:
Dim empVal, empVal1, num

num = 0

empVal = Recordset.Fields.Item("subj").Value

empVal1  = Recordset.Fields.Item("org").Value
here empVal = "" and empVal1 = "" i. e. in the database there are no value i.e. empty

so if i wrote

Code:
If ( (empVal = "") AND (empVal = "") ) Then

 num = num + 1 

 response.write num
 response num

end if
here value should show "1"

But it is not entering within the if condition.

So, how can we evaluate the value of empty
Reply With Quote
  #2 (permalink)  
Old 11-17-07, 13:39
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Try testing for a NULL value as well as an empty string.
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 12-03-07, 03:24
Marvels Marvels is offline
Registered User
 
Join Date: Jul 2003
Location: Amsterdam, Nederland
Posts: 449
Smile re

what i normaly do if i know when a value can be null
is

Dim empVal, empVal1, num
num = 0
empVal = Recordset.Fields.Item("subj").Value & ""
empVal1 = Recordset.Fields.Item("org").Value & ""

so you allways have a empty string value
Reply With Quote
  #4 (permalink)  
Old 12-03-07, 10:40
Teddy Teddy is offline
Purveyor of Discontent
 
Join Date: Mar 2003
Location: The Bottom of The Barrel
Posts: 6,075
That logic is dangerous in general. You can get away with it in certain languages, but you'll find yourself scratching your head when rs("field1") & "" comes back null as you move ahead. It's also confusing to programmers who come in behind you and have to decide what your intent was by concatenating a zero length string to a random field.

But then, I'm nitpicky like that.
__________________
oh yeah... documentation... I have heard of that.

*** What Do You Want In The MS Access Forum? ***
Reply With Quote
  #5 (permalink)  
Old 12-04-07, 08:45
Marvels Marvels is offline
Registered User
 
Join Date: Jul 2003
Location: Amsterdam, Nederland
Posts: 449
Re.RE

Quote:
Originally Posted by Teddy
That logic is dangerous in general. You can get away with it in certain languages, but you'll find yourself scratching your head when rs("field1") & "" comes back null as you move ahead. It's also confusing to programmers who come in behind you and have to decide what your intent was by concatenating a zero length string to a random field.

But then, I'm nitpicky like that.
True , True
Normaly i would use
String.IsNullOrEmpty(y) in .Net
or in VB IsEmpty(x) / IsNothing or IsNULL depending what i was expecting

but in his example he's allready assigning it to a non specified value
' Dim empVal, empVal1, num
without perceding check (so i thought what the heck)
and afterwords he's checking on an empty string
' If ( (empVal = "") AND....

if this is his check, my previus example will work
And if you ask out recordset("Name") & ""
and the rs is Null it will return "" in VB
if rs isn't nothing
don't know if it will do the same in C++
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On