Thanks Dan.
I tried that and yes, you are correct it will work when I use the null
in parentheses. I just thought that null was a reserved word in asp and
did not need to be put in parentheses. What is even more peculiar is
that upon creating an update script for that same field, I had to resort
to dropping the parentheses in order for the code to work.
Here is the code I used for the insert, followed by the update.
idaValue = trim(Request.Form("idaValue"))
if len(idaValue) = 0 then
idaValue = "NULL"
end if
mfdaValue=trim(Request.Form("mfdaValue"))
if len(mfdaValue) = 0 then
mfdaValue = null
end if
-----Original Message-----
From: Dan Powderhill [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 07, 2005 9:51 AM
To: [email protected]
Subject: RE: [AspClassicAnyQuestionIsOk] Leaving field blank in access
database
Are you concatenating your SQL insert string using that value? If so, it
won't put the word null in, it'll add nothing as the value of your
variable is null. So you'll get something like :-
INSERT INTO myTable (idaValue) VALUES ();
...which will cause an error. You could do something like this :-
strSQL = "INSERT INTO myTable (idaValue) VALUES ("
if len(request.form("idaValue")) = 0 then
strSQL = strSQL & "null"
else
strSQL = strSQL & request.form("idaValue")
end if
strSQL = strSQL & ")"
Dan
________________________________
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of
Grinwald, Uri
Sent: 07 July 2005 14:46
To: [email protected]
Subject: RE: [AspClassicAnyQuestionIsOk] Leaving field blank in access
database
Hi.
I was wondering if someone could please assist me.
I am collecting values from a form to insert into an Access DB.
Two of my form fields are of the data type numbers and when the user
leaves these fields blank I get a syntax error in my insert statement.
In my DB those fields arew not required.
I tried the following code but I still have no luck.
idaValue = Request.Form("idaValue")
if idaValue = "" then
idaValue = null
end if
As a test I trield hard codinf any value which does work.
idaValue = Request.Form("idaValue")
if idaValue = "" then
idaValue = 0
end if
Any ideas how I can keep the field blank and return no errors?
Thanks
Uri
________________________________
YAHOO! GROUPS LINKS
* Visit your group "AspClassicAnyQuestionIsOk
<http://groups.yahoo.com/group/AspClassicAnyQuestionIsOk> " on the web.
* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]
subscribe>
* Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service <http://docs.yahoo.com/info/terms/> .
________________________________
[Non-text portions of this message have been removed]
Yahoo! Groups Links
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspClassicAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/