|
-
Nov 2nd, 2004, 10:00 AM
#1
Thread Starter
New Member
Need help checking null values in text type fileds in Visual Basic 5
Hi
I am working on a project in Visual Basic 5 and SQL Server 7 as database where I need to insert and update data in text type fields.
The problem I am facing is that whenever I check for null values in text type fields I am getting an error trying to insert or update.
Is there a way to check for null values in text fields and bypass it if its true.
Any help would be highly appreciated.
Thanks in advance.
-
Nov 2nd, 2004, 10:23 AM
#2
isnull function
add & "" to make it a blank string
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Nov 2nd, 2004, 11:51 PM
#3
Thread Starter
New Member
Need help checking null values in text type fileds in Visual Basic 5
Hi
Thanks for your reply but my problem is that using IsNull function, when I check the text fields, it returns null values even if the text field contains valid data.
Also when I am updating text fields in the database I am getting errors.
Is there a way around.
Thanks
-
Nov 3rd, 2004, 12:07 AM
#4
Hyperactive Member
Thanks for your reply but my problem is that using IsNull function, when I check the text fields, it returns null values even if the text field contains valid data.
if you are testing for null values in SQL, do it like:
Code:
IF YourFld IS NULL
--do your stuff here
ELSE
--YourFld has a value
Also when I am updating text fields in the database I am getting errors.
What exactly is the error?
-
Nov 3rd, 2004, 01:48 AM
#5
Thread Starter
New Member
Need help checking null values in text type fileds in Visual Basic 5
Hi
I get the error invalid use of null. Actually I have got the work around which is to use a temporary variable which I can then check for null instead of check directly the recordset field.
Anyways thanks guys to everybody who responded.
Bye
-
Nov 3rd, 2004, 02:07 AM
#6
Hyperactive Member
Re: Need help checking null values in text type fileds in Visual Basic 5
Originally posted by Jeev
Hi
I get the error invalid use of null. Actually I have got the work around which is to use a temporary variable which I can then check for null instead of check directly the recordset field.
Anyways thanks guys to everybody who responded.
Bye
No need to use a variable.
To get values from a field in your RS object which may contain NULL use:
Code:
rs.Fields("Fld_x").Value & ""
if not, you will get the error invalid use of null
To check if the field is null
Code:
IsNull(rs.Fields("Fld_x").Value)
Also it's always best if you will post the code you're having problem with
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|