|
 |
asp_web_howto thread: MS Access Date - Still need help
Message #1 by "John Miller" <jpmiller@a...> on Wed, 20 Feb 2002 19:29:42
|
|
I posted this problem earlier and got several responses, however I still
have not found a solution. Any help would be greatly appreciated. I have
an ASP application that allows users to input data and Inserts the data
into an MS-Access database. I need to allow them to leave some fields
blank, but if a date ("Date/Time") field is left blank, when the SQL
Insert executes on the next page, the user gets an error, "data type
mismatch in criteria expression." If the date is entered, all is well!
There is not an option in the database to allow zero length.
NULL values cannot be inserted.
HELP....
Thank You in advance for your help.
John Miller
jpmiller@a...
Message #2 by "O'Hara, Elliott M" <EMOHARA@k...> on Wed, 20 Feb 2002 14:33:07 -0500
|
|
why can't nulls be inserted?
Do you want a default date?
-----Original Message-----
From: John Miller [mailto:jpmiller@a...]
Sent: Wednesday, February 20, 2002 2:30 PM
To: ASP Web HowTo
Subject: [asp_web_howto] MS Access Date - Still need help
I posted this problem earlier and got several responses, however I still
have not found a solution. Any help would be greatly appreciated. I have
an ASP application that allows users to input data and Inserts the data
into an MS-Access database. I need to allow them to leave some fields
blank, but if a date ("Date/Time") field is left blank, when the SQL
Insert executes on the next page, the user gets an error, "data type
mismatch in criteria expression." If the date is entered, all is well!
There is not an option in the database to allow zero length.
NULL values cannot be inserted.
HELP....
Thank You in advance for your help.
John Miller
jpmiller@a...
$subst('Email.Unsub').
Message #3 by "Spam Free" <spam.free@n...> on Wed, 20 Feb 2002 20:12:01 -0000
|
|
Hi,
yes sorry... the allow zero length does not apply to date fields
but if you open a database, create a one field table, set the 'required' to
no, enter a space and move to the next field it allows it!!
Why not test the data you are going to save in case the user leaves a blank
for the date field and if so save a dummy date e.g. 01/01/70 ..then on
display of the database field check if the field is 01/01/70 and if it is
don't display the dummy date...
... long winded I know but desperate times call for desperate measures
Good luck
Regards
spam.free@n...
----- Original Message -----
From: "John Miller" <jpmiller@a...>
To: "ASP Web HowTo" <asp_web_howto@p...>
Sent: Wednesday, February 20, 2002 7:29 PM
Subject: [asp_web_howto] MS Access Date - Still need help
> I posted this problem earlier and got several responses, however I still
> have not found a solution. Any help would be greatly appreciated. I have
> an ASP application that allows users to input data and Inserts the data
> into an MS-Access database. I need to allow them to leave some fields
> blank, but if a date ("Date/Time") field is left blank, when the SQL
> Insert executes on the next page, the user gets an error, "data type
> mismatch in criteria expression." If the date is entered, all is well!
>
> There is not an option in the database to allow zero length.
> NULL values cannot be inserted.
>
> HELP....
>
> Thank You in advance for your help.
>
> John Miller
> jpmiller@a...
>
$subst('Email.Unsub').
>
Message #4 by "Ken Schaefer" <ken@a...> on Thu, 21 Feb 2002 12:53:32 +1100
|
|
argh!
When you say "NULL values can not be inserted" does this mean *you* do not
want to let the user insert NULL values? Or do you mean the database isn't
accepting a NULL value?
If the former, then you need a data validation system:
www.adopenstatic.com/resources/code/UIValidation.asp
If the latter, then you are doing something wrong:
<%
dteDate = Request.Form("txtDate")
If not isDate(dteDate) or Len(dteDate) = 0 then
dteDate = 'NULL'
Else
dteDate = "#" & FormatDate(dteDate, "%Y/%m/%d") & "#"
' see www.adopenstatic.com/resources/code/formatdate.asp
End If
strSQL = _
"INSERT INTO table1 " & _
"(field1) " & _
"VALUES(" & dteDate & ")"
%>
will work.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "John Miller" <jpmiller@a...>
Subject: [asp_web_howto] MS Access Date - Still need help
: I posted this problem earlier and got several responses, however I still
: have not found a solution. Any help would be greatly appreciated. I have
: an ASP application that allows users to input data and Inserts the data
: into an MS-Access database. I need to allow them to leave some fields
: blank, but if a date ("Date/Time") field is left blank, when the SQL
: Insert executes on the next page, the user gets an error, "data type
: mismatch in criteria expression." If the date is entered, all is well!
:
: There is not an option in the database to allow zero length.
: NULL values cannot be inserted.
:
: HELP....
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Message #5 by "John" <jpmiller@a...> on Wed, 20 Feb 2002 21:16:03 -0500
|
|
Sorry for the frustration. I cannot insert null values. Perhaps I am
mistaken, but I have been unable to get Access to accept a Null value in a
Date/Time field using a SQL Insert statement.
John Miller
----- Original Message -----
From: Ken Schaefer <ken@a...>
To: ASP Web HowTo <asp_web_howto@p...>
Sent: Wednesday, February 20, 2002 8:53 PM
Subject: [asp_web_howto] Re: MS Access Date - Still need help
> argh!
>
> When you say "NULL values can not be inserted" does this mean *you* do not
> want to let the user insert NULL values? Or do you mean the database isn't
> accepting a NULL value?
>
> If the former, then you need a data validation system:
> www.adopenstatic.com/resources/code/UIValidation.asp
>
> If the latter, then you are doing something wrong:
> <%
> dteDate = Request.Form("txtDate")
> If not isDate(dteDate) or Len(dteDate) = 0 then
> dteDate = 'NULL'
> Else
> dteDate = "#" & FormatDate(dteDate, "%Y/%m/%d") & "#"
> ' see www.adopenstatic.com/resources/code/formatdate.asp
> End If
>
> strSQL = _
> "INSERT INTO table1 " & _
> "(field1) " & _
> "VALUES(" & dteDate & ")"
> %>
>
> will work.
>
> Cheers
> Ken
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> From: "John Miller" <jpmiller@a...>
> Subject: [asp_web_howto] MS Access Date - Still need help
>
>
> : I posted this problem earlier and got several responses, however I still
> : have not found a solution. Any help would be greatly appreciated. I have
> : an ASP application that allows users to input data and Inserts the data
> : into an MS-Access database. I need to allow them to leave some fields
> : blank, but if a date ("Date/Time") field is left blank, when the SQL
> : Insert executes on the next page, the user gets an error, "data type
> : mismatch in criteria expression." If the date is entered, all is well!
> :
> : There is not an option in the database to allow zero length.
> : NULL values cannot be inserted.
> :
> : HELP....
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
$subst('Email.Unsub').
Message #6 by "TomMallard" <mallard@s...> on Wed, 20 Feb 2002 18:45:26 -0800
|
|
Open the table in design view, click on the date/time column and see if
required is set to yes. If it's no, then for inserts in the sql statement
you can insert a null, i.e. "INSERT INTO tablename (dateFieldName)
VALUES('')". If it isn't working it's because of permissions.
tom mallard
seattle
-----Original Message-----
From: John [mailto:jpmiller@a...]
Sent: Wednesday, February 20, 2002 6:16 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Re: MS Access Date - Still need help
Sorry for the frustration. I cannot insert null values. Perhaps I am
mistaken, but I have been unable to get Access to accept a Null value in a
Date/Time field using a SQL Insert statement.
John Miller
----- Original Message -----
From: Ken Schaefer <ken@a...>
To: ASP Web HowTo <asp_web_howto@p...>
Sent: Wednesday, February 20, 2002 8:53 PM
Subject: [asp_web_howto] Re: MS Access Date - Still need help
> argh!
>
> When you say "NULL values can not be inserted" does this mean *you* do not
> want to let the user insert NULL values? Or do you mean the database isn't
> accepting a NULL value?
>
> If the former, then you need a data validation system:
> www.adopenstatic.com/resources/code/UIValidation.asp
>
> If the latter, then you are doing something wrong:
> <%
> dteDate = Request.Form("txtDate")
> If not isDate(dteDate) or Len(dteDate) = 0 then
> dteDate = 'NULL'
> Else
> dteDate = "#" & FormatDate(dteDate, "%Y/%m/%d") & "#"
> ' see www.adopenstatic.com/resources/code/formatdate.asp
> End If
>
> strSQL = _
> "INSERT INTO table1 " & _
> "(field1) " & _
> "VALUES(" & dteDate & ")"
> %>
>
> will work.
>
> Cheers
> Ken
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> From: "John Miller" <jpmiller@a...>
> Subject: [asp_web_howto] MS Access Date - Still need help
>
>
> : I posted this problem earlier and got several responses, however I still
> : have not found a solution. Any help would be greatly appreciated. I have
> : an ASP application that allows users to input data and Inserts the data
> : into an MS-Access database. I need to allow them to leave some fields
> : blank, but if a date ("Date/Time") field is left blank, when the SQL
> : Insert executes on the next page, the user gets an error, "data type
> : mismatch in criteria expression." If the date is entered, all is well!
> :
> : There is not an option in the database to allow zero length.
> : NULL values cannot be inserted.
> :
> : HELP....
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
$subst('Email.Unsub').
$subst('Email.Unsub').
Message #7 by "Drew, Ron" <RDrew@B...> on Thu, 21 Feb 2002 08:12:58 -0500
|
|
Look to see on the MDB if the date/time field is required. I use
date/time on my database for birthdays of husband and wife and do
inserts all the time. Since some people are single birthdays do not
exist for the spouse and my inserts work fine.
-----Original Message-----
From: John Miller [mailto:jpmiller@a...]
Sent: Wednesday, February 20, 2002 2:30 PM
To: ASP Web HowTo
Subject: [asp_web_howto] MS Access Date - Still need help
I posted this problem earlier and got several responses, however I still
have not found a solution. Any help would be greatly appreciated. I have
an ASP application that allows users to input data and Inserts the data
into an MS-Access database. I need to allow them to leave some fields
blank, but if a date ("Date/Time") field is left blank, when the SQL
Insert executes on the next page, the user gets an error, "data type
mismatch in criteria expression." If the date is entered, all is well!
There is not an option in the database to allow zero length. NULL values
cannot be inserted.
HELP....
Thank You in advance for your help.
John Miller
jpmiller@a...
$subst('Email.Unsub').
Message #8 by "John Miller" <jpmiller@a...> on Thu, 21 Feb 2002 18:22:47
|
|
I've tried everything to try to resolve this problem. I've even created a
new table, in the table I created a single date/time field with "required"
set to "NO". I created two new ASP pages with only one text box on the
first page and a simple insert statement on the second page that inserts a
value into the one field in the new table. I still cannot insert a NULL
value into the field.
I created a Query in Access and tried to insert a null value. Access gets
an error that says: "Microsoft Access set 1 field(s) to Null due to a type
conversion failure,... Do you want to run the action query anyway?..." It
does insert a Null value when you click Yes, but I have been unable to
make an ASP page insert a Null value.
Could someone try to duplicate this scenario?
I have about a dozen date/time fields in my application, most of wich need
to be potentially left blank.
Thanks to all who have responded so far, but I'm still in need.
Much Appreciated,
John Miller
jpmiller@a...
> Look to see on the MDB if the date/time field is required. I use
> date/time on my database for birthdays of husband and wife and do
> inserts all the time. Since some people are single birthdays do not
> exist for the spouse and my inserts work fine.
>
> -----Original Message-----
> From: John Miller [mailto:jpmiller@a...]
> Sent: Wednesday, February 20, 2002 2:30 PM
> To: ASP Web HowTo
> Subject: [asp_web_howto] MS Access Date - Still need help
>
>
> I posted this problem earlier and got several responses, however I still
>
> have not found a solution. Any help would be greatly appreciated. I have
>
> an ASP application that allows users to input data and Inserts the
data
> into an MS-Access database. I need to allow them to leave some fields
> blank, but if a date ("Date/Time") field is left blank, when the SQL
> Insert executes on the next page, the user gets an error, "data type
> mismatch in criteria expression." If the date is entered, all is well!
>
> There is not an option in the database to allow zero length. NULL values
> cannot be inserted.
>
> HELP....
>
> Thank You in advance for your help.
>
> John Miller
> jpmiller@a...
>
> $subst('Email.Unsub').
Message #9 by "O'Hara, Elliott M" <EMOHARA@k...> on Thu, 21 Feb 2002 13:20:45 -0500
|
|
send code....
-----Original Message-----
From: John Miller [mailto:jpmiller@a...]
Sent: Thursday, February 21, 2002 1:23 PM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: MS Access Date - Still need help
I've tried everything to try to resolve this problem. I've even created a
new table, in the table I created a single date/time field with "required"
set to "NO". I created two new ASP pages with only one text box on the
first page and a simple insert statement on the second page that inserts a
value into the one field in the new table. I still cannot insert a NULL
value into the field.
I created a Query in Access and tried to insert a null value. Access gets
an error that says: "Microsoft Access set 1 field(s) to Null due to a type
conversion failure,... Do you want to run the action query anyway?..." It
does insert a Null value when you click Yes, but I have been unable to
make an ASP page insert a Null value.
Could someone try to duplicate this scenario?
I have about a dozen date/time fields in my application, most of wich need
to be potentially left blank.
Thanks to all who have responded so far, but I'm still in need.
Much Appreciated,
John Miller
jpmiller@a...
> Look to see on the MDB if the date/time field is required. I use
> date/time on my database for birthdays of husband and wife and do
> inserts all the time. Since some people are single birthdays do not
> exist for the spouse and my inserts work fine.
>
> -----Original Message-----
> From: John Miller [mailto:jpmiller@a...]
> Sent: Wednesday, February 20, 2002 2:30 PM
> To: ASP Web HowTo
> Subject: [asp_web_howto] MS Access Date - Still need help
>
>
> I posted this problem earlier and got several responses, however I still
>
> have not found a solution. Any help would be greatly appreciated. I have
>
> an ASP application that allows users to input data and Inserts the
data
> into an MS-Access database. I need to allow them to leave some fields
> blank, but if a date ("Date/Time") field is left blank, when the SQL
> Insert executes on the next page, the user gets an error, "data type
> mismatch in criteria expression." If the date is entered, all is well!
>
> There is not an option in the database to allow zero length. NULL values
> cannot be inserted.
>
> HELP....
>
> Thank You in advance for your help.
>
> John Miller
> jpmiller@a...
>
> $subst('Email.Unsub').
$subst('Email.Unsub').
Message #10 by "John P. Miller" <jpmiller@a...> on Thu, 21 Feb 2002 13:47:48 -0500
|
|
> send code....
Page 1:
<html>
<head>
<title>Test</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" alink="#00ff00"
vlink="#ff0000" background="backg2.jpg">
<table border="0" width="100%" align="center">
<tr>
<td valign="middle" align="center"><font color="#f8b024"
size=+5>Test<hr></font></td>
</tr>
</table>
<form method="post" action="test2.asp">
<table border="0" width="20%" align="center">
<tr>
<td align="center"><input type="text" name="test"></td>
</tr>
<tr>
<td align="center"><input type="submit" value="Try It"></td>
</tr>
</table>
</form>
</body>
</html>
Page 2:
<% response.buffer=true %>
<% Test = request("test") %>
<% If Test = "" Then
Test = "''"
Else Test = "#" & Test & "#"
End If %>
<%
On error resume next
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\wib\wib.mdb"
SQLTest = "Insert into Test (TestDate) values (" & Test & ")"
response.write SQLTest
Set rsTest = Conn.Execute(SQLTest)
Set rsTest = Nothing
%>
<html>
<head>
<title>Workforce Investment Board</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" alink="#00ff00"
vlink="#ff0000" background="backg2.jpg">
<table border="0" width="100%" align="center">
<tr>
<td valign="middle" align="center"><font color="#f8b024" size=+5>Test
2<hr></font></td>
</tr>
</table>
</body>
</html>
Message #11 by "Jerry Diegel" <diegelj@g...> on Thu, 21 Feb 2002 13:10:09 -0600
|
|
I have written anything for an Access database in years, but, in an
unrelated matter you can convert these two lines of code:
Set rsTest =3D Conn.Execute(SQLTest)
Set rsTest =3D Nothing
to:
Conn.Execute(SQLTest)
Conn.Close
Set Conn =3D Nothing
Also, set Option Explicit, and Dim your variables.
Jerry
-----Original Message-----
From: John P. Miller [mailto:jpmiller@a...]
Sent: Thursday, February 21, 2002 12:48 PM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: MS Access Date - Still need help
> send code....
Page 1:
<html>
<head>
<title>Test</title>
</head>
<body bgcolor=3D"#ffffff" text=3D"#000000" link=3D"#0000ff"
alink=3D"#00ff00"
vlink=3D"#ff0000" background=3D"backg2.jpg">
<table border=3D"0" width=3D"100%" align=3D"center">
<tr>
<td valign=3D"middle" align=3D"center"><font color=3D"#f8b024"
size=3D+5>Test<hr></font></td>
</tr>
</table>
<form method=3D"post" action=3D"test2.asp">
<table border=3D"0" width=3D"20%" align=3D"center">
<tr>
<td align=3D"center"><input type=3D"text" name=3D"test"></td>
</tr>
<tr>
<td align=3D"center"><input type=3D"submit" value=3D"Try It"></td>
</tr>
</table>
</form>
</body>
</html>
Page 2:
<% response.buffer=3Dtrue %>
<% Test =3D request("test") %>
<% If Test =3D "" Then
Test =3D "''"
Else Test =3D "#" & Test & "#"
End If %>
<%
On error resume next
Set Conn =3D Server.CreateObject("ADODB.Connection")
Conn.open "DRIVER=3D{Microsoft Access Driver
(*.mdb)};DBQ=3Dc:\wib\wib.mdb"
SQLTest =3D "Insert into Test (TestDate) values (" & Test & ")"
response.write SQLTest
Set rsTest =3D Conn.Execute(SQLTest)
Set rsTest =3D Nothing
%>
<html>
<head>
<title>Workforce Investment Board</title>
</head>
<body bgcolor=3D"#ffffff" text=3D"#000000" link=3D"#0000ff"
alink=3D"#00ff00"
vlink=3D"#ff0000" background=3D"backg2.jpg">
<table border=3D"0" width=3D"100%" align=3D"center">
<tr>
<td valign=3D"middle" align=3D"center"><font color=3D"#f8b024"
size=3D+5>Test
2<hr></font></td>
</tr>
</table>
</body>
</html>
$subst('Email.Unsub').
Message #12 by william.sze@s... on Thu, 21 Feb 2002 14:57:38 -0500
|
|
Miller,
I would rather work around it by using two INSERT statments:
if TestDate="" then
sql="INSERT tablename (field1) VALUES ('test')
else
sql="INSERT tablename (field1, datefield) VALUES ('test', datTest)
end if
William
"Jerry Diegel"
<diegelj@g... To: "ASP Web HowTo" <asp_web_howto@p...>
ub.com> cc:
Subject: [asp_web_howto] RE: MS Access Date - Still need help
02/21/2002
02:10 PM
Please respond
to "ASP Web
HowTo"
I have written anything for an Access database in years, but, in an
unrelated matter you can convert these two lines of code:
Set rsTest = Conn.Execute(SQLTest)
Set rsTest = Nothing
to:
Conn.Execute(SQLTest)
Conn.Close
Set Conn = Nothing
Also, set Option Explicit, and Dim your variables.
Jerry
-----Original Message-----
From: John P. Miller [mailto:jpmiller@a...]
Sent: Thursday, February 21, 2002 12:48 PM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: MS Access Date - Still need help
> send code....
Page 1:
<html>
<head>
<title>Test</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" alink="#00ff00"
vlink="#ff0000" background="backg2.jpg">
<table border="0" width="100%" align="center">
<tr>
<td valign="middle" align="center"><font color="#f8b024"
size=+5>Test<hr></font></td>
</tr>
</table>
<form method="post" action="test2.asp">
<table border="0" width="20%" align="center">
<tr>
<td align="center"><input type="text" name="test"></td>
</tr>
<tr>
<td align="center"><input type="submit" value="Try It"></td>
</tr>
</table>
</form>
</body>
</html>
Page 2:
<% response.buffer=true %>
<% Test = request("test") %>
<% If Test = "" Then
Test = "''"
Else Test = "#" & Test & "#"
End If %>
<%
On error resume next
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=c:\wib\wib.mdb"
SQLTest = "Insert into Test (TestDate) values (" & Test & ")"
response.write SQLTest
Set rsTest = Conn.Execute(SQLTest)
Set rsTest = Nothing
%>
<html>
<head>
<title>Workforce Investment Board</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#0000ff" alink="#00ff00"
vlink="#ff0000" background="backg2.jpg">
<table border="0" width="100%" align="center">
<tr>
<td valign="middle" align="center"><font color="#f8b024" size=+5>Test
2<hr></font></td>
</tr>
</table>
</body>
</html>
$subst('Email.Unsub').
$subst('Email.Unsub').
Message #13 by "Ken Schaefer" <ken@a...> on Fri, 22 Feb 2002 10:28:51 +1100
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "John P. Miller" <jpmiller@a...>
Subject: [asp_web_howto] RE: MS Access Date - Still need help
: Page 2:
: <% response.buffer=true %>
: <% Test = request("test") %>
: <% If Test = "" Then
: Test = "''"
: Else Test = "#" & Test & "#"
: End If %>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This part is wrong.
If the user did not enter a date, you want to insert the value NULL
If the user did enter a date (eg 1/1/2002) you want to insert the value
#1/1/2002#
So:
<%
If Test = "" then
Test = "NULL"
Else
Test = "#" & Test & "#"
End If
strSQL = "INSERT INTO table1 (field1) VALUES (" & Test & ")"
Response.Write(strSQL)
Response.End
%>
Now, if the user did not enter anything you shoudl get:
INSERT INTO table1 (field1) VALUES (NULL)
If the user did enter a value you should get:
INSERT INTO table1 (field1) VALUES (#1/1/2002#)
Your code is not producing the statements above, which is the problem (I
think)
Cheers
Ken
Message #14 by "O'Hara, Elliott M" <EMOHARA@k...> on Fri, 22 Feb 2002 06:59:52 -0500
|
|
BINGO!!!
Thought that was what the problem was...
some time you just gotta post the code
-----Original Message-----
From: Ken Schaefer [mailto:ken@a...]
Sent: Thursday, February 21, 2002 6:29 PM
To: ASP Web HowTo
Subject: [asp_web_howto] RE: MS Access Date - Still need help
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "John P. Miller" <jpmiller@a...>
Subject: [asp_web_howto] RE: MS Access Date - Still need help
: Page 2:
: <% response.buffer=true %>
: <% Test = request("test") %>
: <% If Test = "" Then
: Test = "''"
: Else Test = "#" & Test & "#"
: End If %>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This part is wrong.
If the user did not enter a date, you want to insert the value NULL
If the user did enter a date (eg 1/1/2002) you want to insert the value
#1/1/2002#
So:
<%
If Test = "" then
Test = "NULL"
Else
Test = "#" & Test & "#"
End If
strSQL = "INSERT INTO table1 (field1) VALUES (" & Test & ")"
Response.Write(strSQL)
Response.End
%>
Now, if the user did not enter anything you shoudl get:
INSERT INTO table1 (field1) VALUES (NULL)
If the user did enter a value you should get:
INSERT INTO table1 (field1) VALUES (#1/1/2002#)
Your code is not producing the statements above, which is the problem (I
think)
Cheers
Ken
$subst('Email.Unsub').
Message #15 by "John Miller" <jpmiller@a...> on Fri, 22 Feb 2002 14:49:20
|
|
Ken is my hero!!!!!!!!!!
I have been banging my head on this for so long. Thanks to everyone who
lended a hand on this, I truly appreciate all your help and your patience.
Thank You,
John Miller
jpmiller@a...
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> From: "John P. Miller" <jpmiller@a...>
> Subject: [asp_web_howto] RE: MS Access Date - Still need help
>
>
> : Page 2:
> : <% response.buffer=true %>
> : <% Test = request("test") %>
> : <% If Test = "" Then
> : Test = "''"
> : Else Test = "#" & Test & "#"
> : End If %>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> This part is wrong.
>
> If the user did not enter a date, you want to insert the value NULL
> If the user did enter a date (eg 1/1/2002) you want to insert the value
> #1/1/2002#
>
> So:
> <%
> If Test = "" then
> Test = "NULL"
> Else
> Test = "#" & Test & "#"
> End If
>
> strSQL = "INSERT INTO table1 (field1) VALUES (" & Test & ")"
> Response.Write(strSQL)
> Response.End
> %>
>
> Now, if the user did not enter anything you shoudl get:
> INSERT INTO table1 (field1) VALUES (NULL)
>
> If the user did enter a value you should get:
> INSERT INTO table1 (field1) VALUES (#1/1/2002#)
>
> Your code is not producing the statements above, which is the problem (I
> think)
>
> Cheers
> Ken
>
|
|
 |