Forums
This topic is locked
Date format with MS Access
Posted 05 Nov 2001 17:04:11
1
has voted
05 Nov 2001 17:04:11 François Chenuz posted:
HelloI have Dreamweaver Ultra Dev 4 and a Data Base MS Access 97
I will insert in a data base MS Access a field with a date (french date dd.mm.yyyy), but when the date is false, the date is reversed.
Field:
Nom text format
Prénom text format
date_nais date format
For example:
When I type 31/02/01(31 february 2001) in my insert page, the date in the MS Access data base become 01.02.31 (1 february 1931).
How can I have a control of the date in Ultra Dev, when the date is false or not the right format.
Thank you very match for your help
François
Here is my code from my insert page:
<%@LANGUAGE="JAVASCRIPT"%>
<!--#include file= »Connections/Sortie.asp » -->
<%
// *** Edit Operations: declare variables
// set the form action variable var MM_editAction = Request.ServerVariables(« URL »; if (Request.QueryString) { MM_editAction += « ? » + Request.QueryString;
}
// boolean to abort record edit
var MM_abortEdit = false;
// query string to execute
var MM_editQuery = « »;
%>
<%
// *** Insert Record: set variables
if (String(Request(« MM_insert ») != « undefined » {
var MM_editConnection = MM_Sortie_STRING; var MM_editTable = « tblAdresse »; var MM_editRedirectUrl = « affichage.asp»; var MM_fieldsStr = « textnom|value|textprenom|value|textdatenais|value »; var MM_columnsStr = « nom|’,none, »|prénom|’,none, »|date_nais|#,none,NULL »;
// create the MM_fields and MM_columns arrays var MM_fields = MM_fieldsStr.split(« | »; var MM_columns = MM_columnsStr.split(« | »;
// set the form values
for (var i=0; i+1 < MM_fields.length; i+=2) {
MM_fields[i+1] = String(Request.Form(MM_fields[i]));
}
// append the query string to the redirect URL
if (MM_editRedirectUrl && Request.QueryString &&
Request.QueryString.length > 0) {
MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf(‘?’<img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle> == -1)? »? »: »& »
 Request.QueryString;
}
}
%>
<%
// *** Insert Record: construct a sql insert statement and execute it
if (String(Request(« MM_insert ») != « undefined » {
// create the sql insert statement
var MM_tableValues = « », MM_dbValues = « »;
for (var i=0; i+1 < MM_fields.length; i+=2) {
var formVal = MM_fields[i+1]; var MM_typesArray = MM_columns[i+1].split(« , »;
var delim = (MM_typesArray[0] != « none » ? MM_typesArray[0] : « »;
var altVal = (MM_typesArray[1] != « none » ? MM_typesArray[1] : « »;
var emptyVal = (MM_typesArray[2] != « none » ? MM_typesArray[2] : « »; if (formVal == « » || formVal == « undefined » { formVal = emptyVal;
} else {
if (altVal != « » {
formVal = altVal;
} else if (delim == « ’ » { // escape quotes
formVal = « ’ » + formVal.replace(/’/g, » » » + « ’ »;
} else {
formVal = delim + formVal + delim;
}
}
MM_tableValues += ((i != 0) ? « , » : « » + MM_columns[i];
MM_dbValues += ((i != 0) ? « , » : « » + formVal;
}
MM_editQuery = « insert into « + MM_editTable + « (« + MM_tableValues + « ) values (« + MM_dbValues + « ) »;
if (!MM_abortEdit) {
// execute the insert var MM_editCmd = Server.CreateObject(‘ADODB.Command’<img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>;
MM_editCmd.ActiveConnection = MM_editConnection;
MM_editCmd.CommandText = MM_editQuery;
MM_editCmd.Execute();
MM_editCmd.ActiveConnection.Close();
if (MM_editRedirectUrl) {
Response.Redirect(MM_editRedirectUrl);
}
}
}
%>
<%
var Affichage = Server.CreateObject(« ADODB.Recordset »;
Affichage.ActiveConnection = MM_Sortie_STRING;
Affichage.Source = « SELECT * FROM tblAdresse »;
Affichage.CursorType = 0;
Affichage.CursorLocation = 2;
Affichage.LockType = 3;
Affichage.Open(); var Affichage_numRows = 0;
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv= »Content-Type » content= »text/html; charset=iso-8859-1 »>
</head>
<body bgcolor= »#FFFFFF » text= »#000000 »>
<form name= »form1 » method= »POST » action= »<%=MM_editAction%> »>
<p>
<input type= »text » name= »textnom »>
Nom</p>
<p>
<input type= »text » name= »textprenom »>
Prénom </p>
<p>
<input type= »text » name= »textdatenais »>
Date de naissance</p>
<p>
<input type= »submit» name=»Submit » value= »Ajout »>
</p>
<input type= »hidden » name= »MM_insert » value= »true»>
</form>
</body>
</html>
<%
Affichage.Close();
%>
Replies
Replied 06 Nov 2001 16:51:20
06 Nov 2001 16:51:20 Ricardo Ribeiro replied:
I have the same problem here. It would be cool if I could pick up the solution for this problem here in these foruns.