|
-
Apr 5th, 2004, 08:43 AM
#1
Thread Starter
Hyperactive Member
Send a null value to a database (conditional)
How I do I send an actual null value to an SQL database? Right now I am sending a empty string but I have to change that to a null. I thought something like this would work but I must be missing something.
VB Code:
Dim strCityTax As String
If txtCityTax.Text = "" Then
strCityTax = DBNull
Else
strCityTax = txtCityTax.Text
End If
That puts a squiggly line under the DBNull with this warning: 'DBNull' is a type and cannot be used as an expression.
-
Apr 5th, 2004, 09:14 AM
#2
Junior Member
the db needs to be able to accept nulls, then send vbNullString
www.mod2software.com
Home of the VB.NET Class Builder Utility - Demo and Full versions available now!
-
Apr 5th, 2004, 09:32 AM
#3
Thread Starter
Hyperactive Member
CattleRustler does that send an emtpy string? I ask because when I go to the field in the database I am not getting the <NULL> to show that the field is indeed null. I get the same type of behavior that I would with an empty string.
-
Apr 13th, 2004, 08:51 PM
#4
Junior Member
what I mean is the field in the db needs to be set to accept null values, then you can send vbNullString from code. If field is set not to accept nulls then you should be able to send "" empty string because it is not theoretically null. Different db's and programming languages may each handle this differently.
www.mod2software.com
Home of the VB.NET Class Builder Utility - Demo and Full versions available now!
-
Apr 13th, 2004, 09:22 PM
#5
Hyperactive Member
Try this..
Code:
strCityTax = DBNull.Value
HTH
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
|