"Spooky" Date problem..... (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


OneEyeViking -> "Spooky" Date problem..... (2/3/2005 8:28:54)

Hi

Sorry for my English, I'm Danish![8|]

I have this weird problem with dates, i know it has been covered many times before but..............

I have generated a Databaseeditor with the DRW, and when i select a record from the list i show in the detail with correct date, when i press edit it still is the correct date.

Now to the problem - when i press OK to update i change the date from dd/mm/yyyy to mm/dd/yyyy.

if I repeat the above the same happends but now it is mm/dd/yyyy to dd/mm/yyyy

It only happends when the day and month values are below 13.

I have tried to user LCID but not with much luck.

I think the trick must be to convert the date my self just before updating the database.

Any ideas?

Regards

Erik




BeTheBall -> RE: "Spooky" Date problem..... (2/3/2005 18:10:20)

Give this a read:

http://www.4guysfromrolla.com/webtech/tips/t022202-1.shtml




OneEyeViking -> RE: "Spooky" Date problem..... (2/4/2005 3:08:51)

Hi Duane

Nice article.

I think it gives the answers.

But where do I put the formatting, it must be just after the user press the OK buttom to update the record.

Erik




BeTheBall -> RE: "Spooky" Date problem..... (2/4/2005 13:48:43)

Does your update form submit to a second page which performs the UPDATE? If so, I would place the function on the page that performs the update. Then, create a variable for your date value, something like:

dtField = JXIsoDate(Request.Form("formDateField"))

Then in your update SQL use the above variable.

Make sense?




OneEyeViking -> RE: "Spooky" Date problem..... (2/4/2005 14:56:08)

Hi Duane

I give You the source and the error, i can't see what to do...

Microsoft VBScript compilation error '800a03ea'

Syntax error

/KK/aktivitet/editor/update.asp, line 37

dtField = JXIsoDate(Request.Form('::DatoN::'))
---------------------------------^

<!--#include File='login.asa'-->
<%
If Session(SiteID) <> true Then
Response.Redirect("Login.asp?requester=update.asp")
End If
%>


<html>

<head>


<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Aktivitet -- Updated Record</title>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>

<body bgcolor="#FFFFCC">
<%
Function JXIsoDate(dteDate)
'Version 1.0
If IsDate(dteDate) = True Then
DIM dteDay, dteMonth, dteYear
dteDay = Day(dteDate)
dteMonth = Month(dteDate)
dteYear = Year(dteDate)
JXIsoDate = dteYear & _
"-" & Right(Cstr(dteMonth + 100),2) & _
"-" & Right(Cstr(dteDay + 100),2)
Else
JXIsoDate = Null
End If
End Function

dtField = JXIsoDate(Request.Form('::DatoN::'))
%>
<script Language="JavaScript">
<!--
top.list.location.href = top.list.location.href;
// -->
</script>

<!--#include file="../../../_fpclass/fpdblib.inc"-->

<%
fp_sQry="UPDATE Aktivitet SET Dato = '::Dato::' , DatoN = dtField , Klokken = '::Klokken::' , KlokkenN = '::KlokkenN::' , Beskrivelse = '::Beskrivelse::' , Sted = '::Sted::' , [Art G/A/M] = '::Field8::' , [By S/K/M/G] = '::Field9::' WHERE (Nummer = ::Nummer::)"
fp_sDefault="Dato=&DatoN=&Klokken=&KlokkenN=&Beskrivelse=&Sted=&Field8=&Field9=&Nummer="
fp_sNoRecords="Record updated in table."
fp_sDataConn="Aktivitet"
fp_iMaxRecords=1
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=False
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes="&"
fp_iDisplayCols=16
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../../../_fpclass/fpdbrgn1.inc"-->
<!--#include file="../../../_fpclass/fpdbrgn2.inc"-->

</body>

</html>

Regards Erik




BeTheBall -> RE: "Spooky" Date problem..... (2/4/2005 15:35:21)

Should be:

dtField = JXIsoDate(Request.Form("DatoN"))

Then, in your SQL change line to:

fp_sQry="UPDATE Aktivitet SET Dato = '::Dato::' , DatoN = #"&dtField&"# , Klokken = '::Klokken::' , KlokkenN = '::KlokkenN::' , Beskrivelse = '::Beskrivelse::' , Sted = '::Sted::' , [Art G/A/M] = '::Field8::' , [By S/K/M/G] = '::Field9::' WHERE (Nummer = ::Nummer::)"




OneEyeViking -> RE: "Spooky" Date problem..... (2/4/2005 17:04:57)

:-)

It did it.

Thanky very much.

Regards Erik




OneEyeViking -> RE: "Spooky" Date problem..... (2/4/2005 17:14:24)

Hi again

Now I only have one problem, where do I do the trick in the "new.asp"?

<%
' FP_ASP ASP Automatically generated by a FrontPage Component. Do not Edit.

On Error Resume Next
Session("FP_OldCodePage") = Session.CodePage
Session("FP_OldLCID") = Session.LCID
Session.CodePage = 1252
Err.Clear

strErrorUrl = ""

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("VTI-GROUP") = "0" Then
Err.Clear

Set fp_conn = Server.CreateObject("ADODB.Connection")
FP_DumpError strErrorUrl, "Cannot create connection"

Set fp_rs = Server.CreateObject("ADODB.Recordset")
FP_DumpError strErrorUrl, "Cannot create record set"

fp_conn.Open Application("Aktivitet_ConnectionString")
FP_DumpError strErrorUrl, "Cannot open database"

fp_rs.Open "Aktivitet", fp_conn, 1, 3, 2 ' adOpenKeySet, adLockOptimistic, adCmdTable
FP_DumpError strErrorUrl, "Cannot open record set"

fp_rs.AddNew
FP_DumpError strErrorUrl, "Cannot add new record set to the database"
Dim arFormFields0(8)
Dim arFormDBFields0(8)
Dim arFormValues0(8)

arFormFields0(0) = "Dato"
arFormDBFields0(0) = "Dato"
arFormValues0(0) = Request("Dato")
arFormFields0(1) = "DatoN"
arFormDBFields0(1) = "DatoN"
arFormValues0(1) = Request("DatoN")
arFormFields0(2) = "Klokken"
arFormDBFields0(2) = "Klokken"
arFormValues0(2) = Request("Klokken")
arFormFields0(3) = "KlokkenN"
arFormDBFields0(3) = "KlokkenN"
arFormValues0(3) = Request("KlokkenN")
arFormFields0(4) = "Beskrivelse"
arFormDBFields0(4) = "Beskrivelse"
arFormValues0(4) = Request("Beskrivelse")
arFormFields0(5) = "Sted"
arFormDBFields0(5) = "Sted"
arFormValues0(5) = Request("Sted")
arFormFields0(6) = "Field8"
arFormDBFields0(6) = "Art G/A/M"
arFormValues0(6) = Request("Field8")
arFormFields0(7) = "Field9"
arFormDBFields0(7) = "By S/K/M/G"
arFormValues0(7) = Request("Field9")

FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0


fp_rs.Update
FP_DumpError strErrorUrl, "Cannot update the database"

fp_rs.Close
fp_conn.Close

Session("FP_SavedFields")=arFormFields0
Session("FP_SavedValues")=arFormValues0
Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")
Response.Redirect "confirm.asp"

End If
End If

Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")

%>
<%Session.LCID=1030%>
<!--#include File='login.asa'-->
<%
If Session(SiteID) <> true Then
Response.Redirect("Login.asp?requester=submission_form.asp")
End If
%>

<% Response.Buffer = True %>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Aktivitet -- New</title>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>

<body bgcolor="#FFFFCC">

<p>

<form METHOD="POST" action="--WEBBOT-SELF--">

<!--webbot bot="SaveDatabase" SuggestedExt="asp" S-DataConnection="Aktivitet" S-RecordSource="Aktivitet" U-Confirmation-Url="confirm.asp" S-Form-Fields="Dato DatoN Klokken KlokkenN Beskrivelse Sted Field8 Field9" S-Form-DBFields="Dato DatoN Klokken KlokkenN Beskrivelse Sted Art\ G/A/M By\ S/K/M/G " B-UseDBFieldsForConfirmation="True" U-ASP-Include-Url="../../../_fpclass/fpdbform.inc" startspan --><input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--#include file="../../../_fpclass/fpdbform.inc"--><!--webbot bot="SaveDatabase" i-checksum="52631" endspan --><table border="0" cellpadding="2" style="border-collapse: collapse" width="100%" id="table1">
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Dato</font></b><font size="1">  
</font></font></td>
<td><font size="1" face="Verdana">
<input type="TEXT" name="DatoN" size="19" value="<%=Date%>">
</font></td>
</tr>
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Klokken</font></b><font size="1"> </font></font></td>
<td><font size="1" face="Verdana">
<input type="TEXT" name="KlokkenN" size="19" value="<%=Time%>"></font></td>
</tr>
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Beskrivelse</font></b><font size="1"> </font></font></td>
<td><font size="1" face="Verdana">
<input type="TEXT" name="Beskrivelse" size="50" value="" maxlength="50"></font></td>
</tr>
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Sted</font></b><font size="1">   
</font></font>
</td>
<td><font size="1" face="Verdana">
<input type="TEXT" name="Sted" size="50" value="" maxlength="50"></font></td>
</tr>
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Art G/A/M</font></b><font size="1"> </font></font></td>
<td><font size="1" face="Verdana">
<%
DIM FpTemp1
FpTemp1 = Field8
%><select size="1" name="Field8">
<option value="A" <%If FpTemp1 = "A" then response.write "selected"%>>A</option>
<option value="G" <%If FpTemp1 = "G" then response.write "selected"%>>G</option>
<option value="M" <%If FpTemp1 = "M" then response.write "selected"%>>M</option>
</select>

<b>G=Gudstjeneste/A=Arrangement/M=Missionshus</b></font></td>
</tr>
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Pastorat</font></b><font size="1"> </font></font></td>
<td><font size="1" face="Verdana">
<%
DIM FpTemp
FpTemp = "Field9"
%><select size="1" name="Field9">
<option value="S" <%If FpTemp = "S" then response.write "selected"%>>S</option>
<option value="K" <%If FpTemp = "K" then response.write "selected"%>>K</option>
<option value="M" <%If FpTemp = "M" then response.write "selected"%>>M</option>
<option value="G" <%If FpTemp = "G" then response.write "selected"%>>G</option>
</select>
<b>S=Storvorde/K=Kongerslev/M=Mou/G=Gudum</b></font></td>
</tr>
<tr>
<td width="70"><font face="Verdana"><input type="submit" value=" OK "></font></td>
<td><font face="Verdana"><input type="reset" value=" Reset "></font></td>
</tr>
</table>

</form>

</body>

</html>

Regards Erik




BeTheBall -> RE: "Spooky" Date problem..... (2/4/2005 18:57:01)

That's a bit tougher as I rarely use the "send to database" option of FP anymore. Make a backup of your current page and then replace your current code with the code below. Not sure whether it will work, but it may:

<%
Function JXIsoDate(dteDate)
'Version 1.0
If IsDate(dteDate) = True Then
DIM dteDay, dteMonth, dteYear
dteDay = Day(dteDate)
dteMonth = Month(dteDate)
dteYear = Year(dteDate)
JXIsoDate = dteYear & _
"-" & Right(Cstr(dteMonth + 100),2) & _
"-" & Right(Cstr(dteDay + 100),2)
Else
JXIsoDate = Null
End If
End Function

dtField = JXIsoDate(Request.Form("DatoN"))

On Error Resume Next
Session("FP_OldCodePage") = Session.CodePage
Session("FP_OldLCID") = Session.LCID
Session.CodePage = 1252
Err.Clear

strErrorUrl = ""

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("VTI-GROUP") = "0" Then
Err.Clear

Set fp_conn = Server.CreateObject("ADODB.Connection")
FP_DumpError strErrorUrl, "Cannot create connection"

Set fp_rs = Server.CreateObject("ADODB.Recordset")
FP_DumpError strErrorUrl, "Cannot create record set"

fp_conn.Open Application("Aktivitet_ConnectionString")
FP_DumpError strErrorUrl, "Cannot open database"

fp_rs.Open "Aktivitet", fp_conn, 1, 3, 2 ' adOpenKeySet, adLockOptimistic, adCmdTable
FP_DumpError strErrorUrl, "Cannot open record set"

fp_rs.AddNew
FP_DumpError strErrorUrl, "Cannot add new record set to the database"
Dim arFormFields0(8)
Dim arFormDBFields0(8)
Dim arFormValues0(8)

arFormFields0(0) = "Dato"
arFormDBFields0(0) = "Dato"
arFormValues0(0) = Request("Dato")
arFormFields0(1) = "DatoN"
arFormDBFields0(1) = "DatoN"
arFormValues0(1) = dtField
arFormFields0(2) = "Klokken"
arFormDBFields0(2) = "Klokken"
arFormValues0(2) = Request("Klokken")
arFormFields0(3) = "KlokkenN"
arFormDBFields0(3) = "KlokkenN"
arFormValues0(3) = Request("KlokkenN")
arFormFields0(4) = "Beskrivelse"
arFormDBFields0(4) = "Beskrivelse"
arFormValues0(4) = Request("Beskrivelse")
arFormFields0(5) = "Sted"
arFormDBFields0(5) = "Sted"
arFormValues0(5) = Request("Sted")
arFormFields0(6) = "Field8"
arFormDBFields0(6) = "Art G/A/M"
arFormValues0(6) = Request("Field8")
arFormFields0(7) = "Field9"
arFormDBFields0(7) = "By S/K/M/G"
arFormValues0(7) = Request("Field9")

FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0


fp_rs.Update
FP_DumpError strErrorUrl, "Cannot update the database"

fp_rs.Close
fp_conn.Close

Session("FP_SavedFields")=arFormFields0
Session("FP_SavedValues")=arFormValues0
Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")
Response.Redirect "confirm.asp"

End If
End If

Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")

%>
<%Session.LCID=1030%>
<!--#include File='login.asa'-->
<%
If Session(SiteID) <> true Then
Response.Redirect("Login.asp?requester=submission_form.asp")
End If
%>

<% Response.Buffer = True %>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Aktivitet -- New</title>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>

<body bgcolor="#FFFFCC">

<p>

<form METHOD="POST" action="--WEBBOT-SELF--">

<<input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--#include file="../../../_fpclass/fpdbform.inc"--><table border="0" cellpadding="2" style="border-collapse: collapse" width="100%" id="table1">
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Dato</font></b><font size="1">  
</font></font></td>
<td><font size="1" face="Verdana">
<input type="TEXT" name="DatoN" size="19" value="<%=Date%>">
</font></td>
</tr>
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Klokken</font></b><font size="1"> </font></font></td>
<td><font size="1" face="Verdana">
<input type="TEXT" name="KlokkenN" size="19" value="<%=Time%>"></font></td>
</tr>
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Beskrivelse</font></b><font size="1"> </font></font></td>
<td><font size="1" face="Verdana">
<input type="TEXT" name="Beskrivelse" size="50" value="" maxlength="50"></font></td>
</tr>
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Sted</font></b><font size="1">   
</font></font>
</td>
<td><font size="1" face="Verdana">
<input type="TEXT" name="Sted" size="50" value="" maxlength="50"></font></td>
</tr>
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Art G/A/M</font></b><font size="1"> </font></font></td>
<td><font size="1" face="Verdana">
<%
DIM FpTemp1
FpTemp1 = Field8
%><select size="1" name="Field8">
<option value="A" <%If FpTemp1 = "A" then response.write "selected"%>>A</option>
<option value="G" <%If FpTemp1 = "G" then response.write "selected"%>>G</option>
<option value="M" <%If FpTemp1 = "M" then response.write "selected"%>>M</option>
</select>

<b>G=Gudstjeneste/A=Arrangement/M=Missionshus</b></font></td>
</tr>
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Pastorat</font></b><font size="1"> </font></font></td>
<td><font size="1" face="Verdana">
<%
DIM FpTemp
FpTemp = "Field9"
%><select size="1" name="Field9">
<option value="S" <%If FpTemp = "S" then response.write "selected"%>>S</option>
<option value="K" <%If FpTemp = "K" then response.write "selected"%>>K</option>
<option value="M" <%If FpTemp = "M" then response.write "selected"%>>M</option>
<option value="G" <%If FpTemp = "G" then response.write "selected"%>>G</option>
</select>
<b>S=Storvorde/K=Kongerslev/M=Mou/G=Gudum</b></font></td>
</tr>
<tr>
<td width="70"><font face="Verdana"><input type="submit" value=" OK "></font></td>
<td><font face="Verdana"><input type="reset" value=" Reset "></font></td>
</tr>
</table>

</form>

</body>

</html>




OneEyeViking -> RE: "Spooky" Date problem..... (2/5/2005 3:33:35)

Hi Duane

Thanks for fast reply [:)]

But it still "turn" the date wrong. [:(]

Regards Erik




BeTheBall -> RE: "Spooky" Date problem..... (2/5/2005 13:47:49)

OK. I should have researched this a bit better before spewing answers. Sorry for that. Use the following code for new.asp

<%

On Error Resume Next
Session("FP_OldCodePage") = Session.CodePage
Session("FP_OldLCID") = Session.LCID
Session.CodePage = 1252
Err.Clear

strErrorUrl = ""

If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
If Request.Form("VTI-GROUP") = "0" Then
Err.Clear

Set fp_conn = Server.CreateObject("ADODB.Connection")
FP_DumpError strErrorUrl, "Cannot create connection"

Set fp_rs = Server.CreateObject("ADODB.Recordset")
FP_DumpError strErrorUrl, "Cannot create record set"

fp_conn.Open Application("Aktivitet_ConnectionString")
FP_DumpError strErrorUrl, "Cannot open database"

fp_rs.Open "Aktivitet", fp_conn, 1, 3, 2 ' adOpenKeySet, adLockOptimistic, adCmdTable
FP_DumpError strErrorUrl, "Cannot open record set"

fp_rs.AddNew
FP_DumpError strErrorUrl, "Cannot add new record set to the database"
Dim arFormFields0(8)
Dim arFormDBFields0(8)
Dim arFormValues0(8)

arFormFields0(0) = "Dato"
arFormDBFields0(0) = "Dato"
arFormValues0(0) = Request("Dato")
arFormFields0(1) = "DatoN"
arFormDBFields0(1) = "DatoN"
arFormValues0(1) = dtField
arFormFields0(2) = "Klokken"
arFormDBFields0(2) = "Klokken"
arFormValues0(2) = Request("Klokken")
arFormFields0(3) = "KlokkenN"
arFormDBFields0(3) = "KlokkenN"
arFormValues0(3) = Request("KlokkenN")
arFormFields0(4) = "Beskrivelse"
arFormDBFields0(4) = "Beskrivelse"
arFormValues0(4) = Request("Beskrivelse")
arFormFields0(5) = "Sted"
arFormDBFields0(5) = "Sted"
arFormValues0(5) = Request("Sted")
arFormFields0(6) = "Field8"
arFormDBFields0(6) = "Art G/A/M"
arFormValues0(6) = Request("Field8")
arFormFields0(7) = "Field9"
arFormDBFields0(7) = "By S/K/M/G"
arFormValues0(7) = Request("Field9")

FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0


fp_rs.Update
FP_DumpError strErrorUrl, "Cannot update the database"

fp_rs.Close
fp_conn.Close

Session("FP_SavedFields")=arFormFields0
Session("FP_SavedValues")=arFormValues0
Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")
Response.Redirect "confirm.asp"

End If
End If

Session.CodePage = Session("FP_OldCodePage")
Session.LCID = Session("FP_OldLCID")

%>
<%Session.LCID=1030%>
<!--#include File='login.asa'-->
<%
If Session(SiteID) <> true Then
Response.Redirect("Login.asp?requester=submission_form.asp")
End If
%>

<% Response.Buffer = True %>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Aktivitet -- New</title>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>

<body bgcolor="#FFFFCC">

<p>

<form METHOD="POST" action="--WEBBOT-SELF--">

<<input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--#include file="../../../_fpclass/fpdbform2.inc"--><table border="0" cellpadding="2" style="border-collapse: collapse" width="100%" id="table1">
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Dato</font></b><font size="1">  
</font></font></td>
<td><font size="1" face="Verdana">
<input type="TEXT" name="DatoN" size="19" value="<%=Date%>">
</font></td>
</tr>
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Klokken</font></b><font size="1"> </font></font></td>
<td><font size="1" face="Verdana">
<input type="TEXT" name="KlokkenN" size="19" value="<%=Time%>"></font></td>
</tr>
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Beskrivelse</font></b><font size="1"> </font></font></td>
<td><font size="1" face="Verdana">
<input type="TEXT" name="Beskrivelse" size="50" value="" maxlength="50"></font></td>
</tr>
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Sted</font></b><font size="1">   
</font></font>
</td>
<td><font size="1" face="Verdana">
<input type="TEXT" name="Sted" size="50" value="" maxlength="50"></font></td>
</tr>
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Art G/A/M</font></b><font size="1"> </font></font></td>
<td><font size="1" face="Verdana">
<%
DIM FpTemp1
FpTemp1 = Field8
%><select size="1" name="Field8">
<option value="A" <%If FpTemp1 = "A" then response.write "selected"%>>A</option>
<option value="G" <%If FpTemp1 = "G" then response.write "selected"%>>G</option>
<option value="M" <%If FpTemp1 = "M" then response.write "selected"%>>M</option>
</select>

<b>G=Gudstjeneste/A=Arrangement/M=Missionshus</b></font></td>
</tr>
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Pastorat</font></b><font size="1"> </font></font></td>
<td><font size="1" face="Verdana">
<%
DIM FpTemp
FpTemp = "Field9"
%><select size="1" name="Field9">
<option value="S" <%If FpTemp = "S" then response.write "selected"%>>S</option>
<option value="K" <%If FpTemp = "K" then response.write "selected"%>>K</option>
<option value="M" <%If FpTemp = "M" then response.write "selected"%>>M</option>
<option value="G" <%If FpTemp = "G" then response.write "selected"%>>G</option>
</select>
<b>S=Storvorde/K=Kongerslev/M=Mou/G=Gudum</b></font></td>
</tr>
<tr>
<td width="70"><font face="Verdana"><input type="submit" value=" OK "></font></td>
<td><font face="Verdana"><input type="reset" value=" Reset "></font></td>
</tr>
</table>

</form>

</body>

</html>


Then go to the _fpclass folder and with Notepad, open fpdbform.inc. Paste this at the very beginning of the file (right after the <%):


Function JXIsoDate(dteDate)
'Version 1.0
If IsDate(dteDate) = True Then
DIM dteDay, dteMonth, dteYear
dteDay = Day(dteDate)
dteMonth = Month(dteDate)
dteYear = Year(dteDate)
JXIsoDate = dteYear & _
"-" & Right(Cstr(dteMonth + 100),2) & _
"-" & Right(Cstr(dteDay + 100),2)
Else
JXIsoDate = Null
End If
End Function

Then scroll down until you find:

Case adDate Or adDBDate Or adDBTime or adDBTimeStamp
rs(strDBField) = CDate(strField)

and change it to:

Case adDate Or adDBDate Or adDBTime or adDBTimeStamp
rs(strDBField) = JXIsoDate(strField)

Save the page as fpdbform2.inc. In the code I gave you for new.asp I have already changed the name of the include file to match. I am fairly certain that will work. Then if you create other submit forms that have dates, you can change the include from fpdbform.inc to fpdbform2.inc in them as well. Or, if you know you will always need to convert the dates, just make the above changes and keep the file named fpdbform.inc and the function will always be called when submitting values to db date fields.




OneEyeViking -> RE: "Spooky" Date problem..... (2/5/2005 16:03:59)

Hi again Duane

I'm very pleased You take the time to help me!

But it doesn't work, I'm very sorry.

Regards Erik




BeTheBall -> RE: "Spooky" Date problem..... (2/5/2005 20:39:27)

Erik, what you may have to do then is copy your form to a new page and then right-click it and choose form properties. Then instead of choosing the "Send to database" option, choose "Send to other". Then, in the action type, Insert.asp. Then create a new page, and of course, name it Insert.asp. On it, insert a DRW using a custom SQL statement. The custom statement will need to be an Insert statement to insert the new record. Also on the page include the custom function for converting the date and then modify the date part of the insert statement the same way you modified it for your update statement.




OneEyeViking -> RE: "Spooky" Date problem..... (2/6/2005 16:47:21)

Hi Duane

I have tried to do, but mayby I don't understand. Anyway I can't get it working.

Is it possible, You know where I can see an example?

Regards Erik




BeTheBall -> RE: "Spooky" Date problem..... (2/6/2005 16:48:35)

Can you post what you have tried and any error messages you may be getting?




OneEyeViking -> RE: "Spooky" Date problem..... (2/6/2005 17:23:28)

Hi

Here is the submission:
<%Session.LCID=1030%>
<!--#include File='login.asa'-->
<%
If Session(SiteID) <> true Then
Response.Redirect("Login.asp?requester=submission_form.asp")
End If
%>

<% Response.Buffer = True %>

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Aktivitet -- New</title>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>

<body bgcolor="#FFFFCC">

<p>

<form METHOD="POST" action="insert.asp">

<input TYPE="hidden" NAME="VTI-GROUP" VALUE="0"><!--#include file="../../../_fpclass/fpdbform.inc"-->

<table border="0" cellpadding="2" style="border-collapse: collapse" width="100%" id="table1">
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Dato</font></b><font size="1">
</font></font></td>
<td><font size="1" face="Verdana">
<input type="TEXT" name="DatoN" size="19" value="<%=Date%>">
</font></td>
</tr>
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Klokken</font></b><font size="1"> </font></font></td>
<td><font size="1" face="Verdana">
<input type="TEXT" name="KlokkenN" size="19" value="<%=Time%>"></font></td>
</tr>
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Beskrivelse</font></b><font size="1"> </font></font></td>
<td><font size="1" face="Verdana">
<input type="TEXT" name="Beskrivelse" size="50" value="" maxlength="50"></font></td>
</tr>
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Sted</font></b><font size="1">
</font></font>
</td>
<td><font size="1" face="Verdana">
<input type="TEXT" name="Sted" size="50" value="" maxlength="50"></font></td>
</tr>
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Art G/A/M</font></b><font size="1"> </font></font></td>
<td><font size="1" face="Verdana">
<%
DIM FpTemp1
FpTemp1 = Field8
%><select size="1" name="Field8">
<option value="A" <%If FpTemp1 = "A" then response.write "selected"%>>A</option>
<option value="G" <%If FpTemp1 = "G" then response.write "selected"%>>G</option>
<option value="M" <%If FpTemp1 = "M" then response.write "selected"%>>M</option>
</select>

<b>G=Gudstjeneste/A=Arrangement/M=Missionshus</b></font></td>
</tr>
<tr>
<td width="70" bgcolor="#FF9900"><font face="Verdana"><b><font size="1">Pastorat</font></b><font size="1"> </font></font></td>
<td><font size="1" face="Verdana">
<%
DIM FpTemp
FpTemp = "Field9"
%><select size="1" name="Field9">
<option value="S" <%If FpTemp = "S" then response.write "selected"%>>S</option>
<option value="K" <%If FpTemp = "K" then response.write "selected"%>>K</option>
<option value="M" <%If FpTemp = "M" then response.write "selected"%>>M</option>
<option value="G" <%If FpTemp = "G" then response.write "selected"%>>G</option>
</select>
<b>S=Storvorde/K=Kongerslev/M=Mou/G=Gudum</b></font></td>
</tr>
<tr>
<td width="70"><font face="Verdana"><input type="submit" value=" OK "></font></td>
<td><font face="Verdana"><input type="reset" value=" Reset "></font></td>
</tr>
</table>

</form>

</body>

</html>

and here the insert.asp:
<%
Function JXIsoDate(dteDate)
'Version 1.0
If IsDate(dteDate) = True Then
DIM dteDay, dteMonth, dteYear
dteDay = Day(dteDate)
dteMonth = Month(dteDate)
dteYear = Year(dteDate)
JXIsoDate = dteYear & _
"-" & Right(Cstr(dteMonth + 100),2) & _
"-" & Right(Cstr(dteDay + 100),2)
Else
JXIsoDate = Null
End If
End Function

dtField = JXIsoDate(Request.Form("DatoN"))
%>

<html>

<head>
<meta http-equiv="Content-Type">
<title>Aktivitet -- Confirm</title>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>

<script Language="JavaScript">
<!--
top.list.location.href = top.list.location.href;
// -->
</script>

<body bgcolor="#FFFFCC">


<!--#include file="../../../_fpclass/fpdblib.inc"-->
<%
fp_sQry="INSERT INTO Aktivitet (Nummer, Dato, DatoN, Klokken, KlokkenN, Beskrivelse, Sted, [Art G/A/M], [By S/K/M/G]) VALUES (::Nummer::, ::Dato::, #"&dtField&"#, ::Klokken::, ::KlokkenN::, ::Beskrivelse::, ::Sted::, ::[Art G/A/M]::, ::[By S/K/M/G]::)"
fp_sDefault="DatoN=&KlokkenN=&Beskrivelse=&Sted="
fp_sNoRecords="No records returned."
fp_sDataConn="Aktivitet"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=1
fp_fTableFormat=False
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes="&"
fp_iDisplayCols=16
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../../../_fpclass/fpdbrgn1.inc"-->
<!--#include file="../../../_fpclass/fpdbrgn2.inc"-->


</body>

</html>

and here the error:
Database Results Error
Description: Syntax error in INSERT INTO statement.
Number: -2147217900 (0x80040E14)
Source: Microsoft JET Database Engine

One or more form fields were empty. You should provide default values for all form fields that are used in the query.

Regards Erik




BeTheBall -> RE: "Spooky" Date problem..... (2/6/2005 17:53:07)

What are the data types of each of these fields:

Nummer, Dato, DatoN, Klokken, KlokkenN, Beskrivelse, Sted, [Art G/A/M], [By S/K/M/G]

Text, numeric or date?




OneEyeViking -> RE: "Spooky" Date problem..... (2/6/2005 17:58:31)

Hi

Nummer : Autonumber
Dato : Text
DatoN : Date/Time
Klokken : Text
KlokkenN : Date/Time
Beskrivelse : Text
Sted : Text
[Art G/A/M] : Text
[By S/K/M/G] : Text

Regards Erik




BeTheBall -> RE: "Spooky" Date problem..... (2/6/2005 18:04:13)

quote:

ORIGINAL: OneEyeViking

Hi

Nummer : Autonumber
Dato : Text
DatoN : Date/Time
Klokken : Text
KlokkenN : Date/Time
Beskrivelse : Text
Sted : Text
[Art G/A/M] : Text
[By S/K/M/G] : Text

Regards Erik


Don't include an autonumber field in your SQL. Access will take care of that for you. The other thing you need to know is that you surround text fields with single quotes, dates with ## and nothing for numeric fields. Like this:

fp_sQry="INSERT INTO Aktivitet (Dato, DatoN, Klokken, KlokkenN, Beskrivelse, Sted, [Art G/A/M], [By S/K/M/G]) VALUES ('::Dato::', #"&dtField&"#, '::Klokken::', #::KlokkenN::#, '::Beskrivelse::', '::Sted::', '::[Art G/A/M]::', '::[By S/K/M/G]::')"




OneEyeViking -> RE: "Spooky" Date problem..... (2/6/2005 18:20:26)

Hi Duane

Now everything is fine [:D]

Regards Erik




OneEyeViking -> RE: "Spooky" Date problem..... (2/23/2005 9:50:20)

Hi again Duane

I still have some problems :-(

Here is the error:

Database Results Error
Description: Syntax error in date in query expression '##'.
Number: -2147217913 (0x80040E07)
Source: Microsoft JET Database Engine

and here is the code:
<html>

<head>
<meta http-equiv="Content-Type">
<title>Aktivitet -- Confirm</title>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<link rel='stylesheet' type='text/css' href='../../../include/ag1.css'/>
</head>

<script Language="JavaScript">
<!--
top.list.location.href = top.list.location.href;
// -->
</script>

<body bgcolor="#FFFFCC">
<%
Function JXIsoDate(dteDate)
'Version 1.0
If IsDate(dteDate) = True Then
DIM dteDay, dteMonth, dteYear
dteDay = Day(dteDate)
dteMonth = Month(dteDate)
dteYear = Year(dteDate)
JXIsoDate = dteYear & _
"-" & Right(Cstr(dteMonth + 100),2) & _
"-" & Right(Cstr(dteDay + 100),2)
Else
JXIsoDate = Null
End If
End Function

dtField = JXIsoDate(Request.Form("Dato"))
%>

<!--#include file="../../../_fpclass/fpdblib.inc"-->
<%
fp_sQry="INSERT INTO Arrang (Dato, Klokken, Sted, Overskrift, Beskrivelse, Billede) VALUES (#"&dtField&"#, '::Klokken::', '::Sted::', '::Overskrift::', '::Beskrivelse::', '::Billede::')"
fp_sDefault="Dato=&Klokken=&Sted=&Overskrift=&Beskrivelse=&Billede="
fp_sNoRecords="No records returned."
fp_sDataConn="Aktivitet"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=1
fp_fTableFormat=False
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes="&"
fp_iDisplayCols=16
fp_fCustomQuery=True
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../../../_fpclass/fpdbrgn1.inc"-->
<!--#include file="../../../_fpclass/fpdbrgn2.inc"-->


</body>

</html>

Hope u have some ideas.

Regards Erik




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.125