|
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.
|
|
|
|