|
-
January 27th, 2005, 07:33 AM
#1
INSERT nullstring INTO
I execute an SQL statement "INSERT INTO ... VALUES ...", but if one of the values is null string ("") then SQL fails. What can I do for this?
I am using VB6, ADO 2.7 and Access 2000.
-
January 27th, 2005, 08:21 AM
#2
Re: INSERT nullstring INTO
Resolved: I had a field with name DATE which conflicts with the DATE function of VB. I changed its name to BILLDATE and now it works no matter if there is null string or not.
-
January 28th, 2005, 01:47 AM
#3
Re: INSERT nullstring INTO
Date is also a Reserved word in Access..u may want to consider change the field name or use [] bracket
-
January 28th, 2005, 03:44 AM
#4
Re: INSERT nullstring INTO
Is there any reason you are inserting an empty string "" rather than NULL?
-
January 28th, 2005, 07:02 AM
#5
Re: INSERT nullstring INTO
but if one of the values is null string ("") then SQL fails. What can I do for this?
Generaly speaking this is a very bad idea to concatenate strings for executing SQL in ADO.I'm almost sure that U've done something like that: strSQL="INSERT INTO .... VALUES('" & strVar1 & "')".
It leads to "SQL injection" problem (and also to a problem that U discover ).
Proper (and safe) way to do it is to execute parametrized SQL in ADO.
Best regards,
Krzemo.
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
|