|
-
Dec 28th, 2007, 07:08 PM
#1
Thread Starter
Hyperactive Member
[2005] is there a special VB/Access null value?
I remember something from college about there being some special null value that you have to use when writing to an Access database. Right now a bunch of text fields in the DB are Allow Zero Length: No. So when I try and send it this statement:
INSERT INTO [DOG DATA] ([OWNER ID],BREED,SEX,[SEX ENTRY],[CALL NAME],[DATE OF BIRTH],[PLACE OF BIRTH],BREEDER,SIRE,DAM, [DOG HEIGHT],[NADAC REG NUM],[NADAC DOG HEIGHT],[NADAC MEASURED JUMP HEIGHT]) VALUES (379,'border collie','Female','2','Taka','02/14/2001','','','','',21,'07-04215',21,'16')
it gives me an error about the value of those red ones being a zero length string. I'm using string variables to build the SQL statement's values right now. Is there some value I can assign them that it will accept like "NULL" or something? I recall using something like VBNULL or DBNULL or something a long time ago but nothing I've tried worked so far.
I tried to end process on Visual Studio 2005
but PETA stopped me saying it's smart enough
to be a living creature 
-
Dec 28th, 2007, 07:12 PM
#2
Re: [2005] is there a special VB/Access null value?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Dec 28th, 2007, 07:16 PM
#3
Re: [2005] is there a special VB/Access null value?
My usual boring signature: Nothing
 
-
Dec 28th, 2007, 08:09 PM
#4
Thread Starter
Hyperactive Member
Re: [2005] is there a special VB/Access null value?
If I use nothing doesn't that wipe it from memory completely and you can't use the variable after that? And DBNull sounds more familiar but do I just do somestringvar = DBNull?
I tried to end process on Visual Studio 2005
but PETA stopped me saying it's smart enough
to be a living creature 
-
Dec 29th, 2007, 03:44 AM
#5
Re: [2005] is there a special VB/Access null value?
If you're writing a null value as a literal in an SQL statement then it's just NULL, with no double or single quotes. If you are inserting a value into a parameter or field in VB code then you want the DBNull.Value property.
-
Dec 29th, 2007, 08:50 PM
#6
Thread Starter
Hyperactive Member
Re: [2005] is there a special VB/Access null value?
ohhhh I gotcha. Hopefully Access isn't too retarded to take NULL. I dunno if it'll still consider that a zero length string but I'll find out. I really, really don't want to write a dozen if statements that remove that field from the insert statement if they're blank so hopefully it will work
I tried to end process on Visual Studio 2005
but PETA stopped me saying it's smart enough
to be a living creature 
-
Dec 29th, 2007, 09:02 PM
#7
Re: [2005] is there a special VB/Access null value?
NULL is not a zero length string and vice versa. In VB, is an empty string the same as Nothing? No it's not. One is an object containing no characters and the other is no object at all. The same is true in databases.
-
Dec 29th, 2007, 09:23 PM
#8
Thread Starter
Hyperactive Member
-
Dec 29th, 2007, 09:30 PM
#9
Re: [2005] is there a special VB/Access null value?
I did not say that you should assign Nothing anywhere. I was using the difference between Nothing and an empty string in VB to illustrate the difference between NULL and an empty string in a database. I already explained what you needed to do in post #5.
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
|