Avatar of ullenulle
ullenulle
Flag for United States of America asked on

Form won't update when a date-field is empty...

Hi there.

I have a problem that is making me insane... I have a page with check-boxes, text-fields and date-fields. I usually create the basics in Dreamweaver CS3 first and edit the SQL-codes afterwards, because I write one session to two tables (logging). Anyway... I attached my entire page here. Please tell me whyyyyyyyyyyy I get this error:

Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[MySQL][ODBC 5.1 Driver][mysqld-5.0.51b-community-nt]Incorrect date value: '' for column 'mmm_behandling_hyperterm_tnfalfa_dato' at row 1
/melanom/melanom_onstudy2.asp, line 139

 when I either update an existing record or create a new record AND in either case the four date-fields has no value???? It works fine with the normal Dreamweaver-codes, and it used to work on a lot of other forms I made with the modified SQL-codes. But somehow I must have made something wrong. I just can't figure out what...
Please HEEEEEEELP!!!!
I use classic asp and MySQL.

Best regards

Ullenulle
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include virtual="top_secret.asp" -->
<!--#include file="IsLoggedIn.asp"-->
<%Response.Cookies("melanomcookie").Expires = DateAdd("n", +60, FormatDateTime(Now,vbGeneralDate))%>
<%username=Request.Cookies("melanomcookie")("User")%>
<%userlevel=Request.Cookies("melanomcookie")("Usertype")%>
<%usercenter=Request.Cookies("melanomcookie")("Usercenter")%>
<SCRIPT LANGUAGE="JavaScript">
<!--
top.window.moveTo(0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}
//-->
</script>
<% 
    pStr = "private, no-cache, must-revalidate" 
    Response.Expires = 60 
    Response.AddHeader "pragma", "no-cache" 
    Response.AddHeader "cache-control", pStr 
%>
<%
Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
  If condition = "" Then
    MM_IIf = ifFalse
  Else
    MM_IIf = ifTrue
  End If
End Function
%>
<%
If (CStr(Request("MM_insert")) = "form1") Then
  If (Not MM_abortEdit) Then
    ' execute the insert
	
	Dim xusername, xpatient_id_onstudy2, xmmm_behandling_none, xmmm_behandling_kirurgi, xmmm_behandling_kirurgi_beskriv, xmmm_behandling_kirurgi_dato, xmmm_behandling_radio, xmmm_behandling_radioterapi_beskriv, xmmm_behandling_radioterapi_dato, xmmm_behandling_hyperterm_melphalan, xmmm_behandling_hyperterm_melphalan_beskriv, xmmm_behandling_hyperterm_melphalan_dato, xmmm_behandling_hyperterm_tnfalfa, xmmm_behandling_hyperterm_tnfalfa_beskriv, xmmm_behandling_hyperterm_tnfalfa_dato, xmetastase_lunge, xmetastase_lever, xmetastase_milt, xmetastase_binyre, xmetastase_kutane, xmetastase_subkutane, xmetastase_knogle, xmetastase_lymfeknude, xmetastase_andet, xmetastase_andet_beskriv, xudbredning_verificeret
	Dim sConnString, objConn, sSQL, sSQL1
	xusername = Request.Cookies("melanomcookie")("User")
	xpatient_id_onstudy2 = Request.Form("patient_id_onstudy2")
	xmmm_behandling_none = MM_IIF(Request.Form("mmm_behandling_none"), 1, 0)
	xmmm_behandling_kirurgi = MM_IIF(Request.Form("mmm_behandling_kirurgi"), 1, 0)
	xmmm_behandling_kirurgi_beskriv = Request.Form("mmm_behandling_kirurgi_beskriv")
	xmmm_behandling_kirurgi_dato = MM_IIF(Request.Form("mmm_behandling_kirurgi_dato"), Request.Form("mmm_behandling_kirurgi_dato"), null)
	xmmm_behandling_radio = MM_IIF(Request.Form("mmm_behandling_radio"), 1, 0)
	xmmm_behandling_radioterapi_beskriv = Request.Form("mmm_behandling_radioterapi_beskriv")
	xmmm_behandling_radioterapi_dato = MM_IIF(Request.Form("mmm_behandling_radioterapi_dato"), Request.Form("mmm_behandling_radioterapi_dato"), null)
	xmmm_behandling_hyperterm_melphalan = MM_IIF(Request.Form("mmm_behandling_hyperterm_melphalan"), 1, 0)
	xmmm_behandling_hyperterm_melphalan_beskriv = Request.Form("mmm_behandling_hyperterm_melphalan_beskriv")
	xmmm_behandling_hyperterm_melphalan_dato = MM_IIF(Request.Form("mmm_behandling_hyperterm_melphalan_dato"), Request.Form("mmm_behandling_hyperterm_melphalan_dato"), null)
	xmmm_behandling_hyperterm_tnfalfa = MM_IIF(Request.Form("mmm_behandling_hyperterm_tnfalfa"), 1, 0)
	xmmm_behandling_hyperterm_tnfalfa_beskriv = Request.Form("mmm_behandling_hyperterm_tnfalfa_beskriv")
	xmmm_behandling_hyperterm_tnfalfa_dato = MM_IIF(Request.Form("mmm_behandling_hyperterm_tnfalfa_dato"), Request.Form("mmm_behandling_hyperterm_tnfalfa_dato"), null)
	xmetastase_lunge = MM_IIF(Request.Form("metastase_lunge"), 1, 0)
	xmetastase_lever = MM_IIF(Request.Form("metastase_lever"), 1, 0)
	xmetastase_milt = MM_IIF(Request.Form("metastase_milt"), 1, 0)
	xmetastase_binyre = MM_IIF(Request.Form("metastase_binyre"), 1, 0)
	xmetastase_kutane = MM_IIF(Request.Form("metastase_kutane"), 1, 0)
	xmetastase_subkutane = MM_IIF(Request.Form("metastase_subkutane"), 1, 0)
	xmetastase_knogle = MM_IIF(Request.Form("metastase_knogle"), 1, 0)
	xmetastase_lymfeknude = MM_IIF(Request.Form("metastase_lymfeknude"), 1, 0)
	xmetastase_andet = MM_IIF(Request.Form("metastase_andet"), 1, 0)
	xmetastase_andet_beskriv = Request.Form("metastase_andet_beskriv")
	xudbredning_verificeret = Request.Form("udbredning_verificeret")
	xpatient_id_behandling = Request.Form("patient_id_behandling")
	xafter_serie = Request.Form("after_serie")
	xintrona = Request.Form("introna")
	xpeg_introna = Request.Form("peg_introna")
	xil_2 = Request.Form("il_2")
	sConnString = MM_conmelanom_STRING
	Set objConn = Server.CreateObject("ADODB.Connection")
	objConn.Open(sConnString) 
	sSQL = "INSERT INTO tbl_onstudy2 (username, patient_id_onstudy2, mmm_behandling_none, mmm_behandling_kirurgi, mmm_behandling_kirurgi_beskriv, mmm_behandling_kirurgi_dato, mmm_behandling_radio, mmm_behandling_radioterapi_beskriv, mmm_behandling_radioterapi_dato, mmm_behandling_hyperterm_melphalan, mmm_behandling_hyperterm_melphalan_beskriv, mmm_behandling_hyperterm_melphalan_dato, mmm_behandling_hyperterm_tnfalfa, mmm_behandling_hyperterm_tnfalfa_beskriv, mmm_behandling_hyperterm_tnfalfa_dato, metastase_lunge, metastase_lever, metastase_milt, metastase_binyre, metastase_kutane, metastase_subkutane, metastase_knogle, metastase_lymfeknude, metastase_andet, metastase_andet_beskriv, udbredning_verificeret) VALUES ('" & xusername & "','" & xpatient_id_onstudy2 & "','" & xmmm_behandling_none & "','" & xmmm_behandling_kirurgi & "','" & xmmm_behandling_kirurgi_beskriv & "','" & xmmm_behandling_kirurgi_dato & "','" & xmmm_behandling_radio & "','" & xmmm_behandling_radioterapi_beskriv & "','" & xmmm_behandling_radioterapi_dato & "','" & xmmm_behandling_hyperterm_melphalan & "','" & xmmm_behandling_hyperterm_melphalan_beskriv & "','" & xmmm_behandling_hyperterm_melphalan_dato & "','" & xmmm_behandling_hyperterm_tnfalfa & "','" & xmmm_behandling_hyperterm_tnfalfa_beskriv & "','" & xmmm_behandling_hyperterm_tnfalfa_dato & "','" & xmetastase_lunge & "','" & xmetastase_lever & "','" & xmetastase_milt & "','" & xmetastase_binyre & "','" & xmetastase_kutane & "','" & xmetastase_subkutane & "','" & xmetastase_knogle & "','" & xmetastase_lymfeknude & "','" & xmetastase_andet & "','" & xmetastase_andet_beskriv & "','" & xudbredning_verificeret & "')"
	sSQL1 = "INSERT INTO tbl_onstudy2_log (username, patient_id_onstudy2, mmm_behandling_none, mmm_behandling_kirurgi, mmm_behandling_kirurgi_beskriv, mmm_behandling_kirurgi_dato, mmm_behandling_radio, mmm_behandling_radioterapi_beskriv, mmm_behandling_radioterapi_dato, mmm_behandling_hyperterm_melphalan, mmm_behandling_hyperterm_melphalan_beskriv, mmm_behandling_hyperterm_melphalan_dato, mmm_behandling_hyperterm_tnfalfa, mmm_behandling_hyperterm_tnfalfa_beskriv, mmm_behandling_hyperterm_tnfalfa_dato, metastase_lunge, metastase_lever, metastase_milt, metastase_binyre, metastase_kutane, metastase_subkutane, metastase_knogle, metastase_lymfeknude, metastase_andet, metastase_andet_beskriv, udbredning_verificeret) VALUES ('" & xusername & "','" & xpatient_id_onstudy2 & "','" & xmmm_behandling_none & "','" & xmmm_behandling_kirurgi & "','" & xmmm_behandling_kirurgi_beskriv & "','" & xmmm_behandling_kirurgi_dato & "','" & xmmm_behandling_radio & "','" & xmmm_behandling_radioterapi_beskriv & "','" & xmmm_behandling_radioterapi_dato & "','" & xmmm_behandling_hyperterm_melphalan & "','" & xmmm_behandling_hyperterm_melphalan_beskriv & "','" & xmmm_behandling_hyperterm_melphalan_dato & "','" & xmmm_behandling_hyperterm_tnfalfa & "','" & xmmm_behandling_hyperterm_tnfalfa_beskriv & "','" & xmmm_behandling_hyperterm_tnfalfa_dato & "','" & xmetastase_lunge & "','" & xmetastase_lever & "','" & xmetastase_milt & "','" & xmetastase_binyre & "','" & xmetastase_kutane & "','" & xmetastase_subkutane & "','" & xmetastase_knogle & "','" & xmetastase_lymfeknude & "','" & xmetastase_andet & "','" & xmetastase_andet_beskriv & "','" & xudbredning_verificeret & "')"
	objConn.execute(sSQL)
	objConn.execute(sSQL1)
	objConn.Close
	Set objConn = nothing
	
  End If
End If
%>
<%
If (CStr(Request("MM_update")) = "form2") Then
  If (Not MM_abortEdit) Then
    ' execute the update

	Dim xusername2, xpatient_id_onstudy22, xmmm_behandling_none2, xmmm_behandling_kirurgi2, xmmm_behandling_kirurgi_beskriv2, xmmm_behandling_kirurgi_dato2, xmmm_behandling_radio2, xmmm_behandling_radioterapi_beskriv2, xmmm_behandling_radioterapi_dato2, xmmm_behandling_hyperterm_melphalan2, xmmm_behandling_hyperterm_melphalan_beskriv2, xmmm_behandling_hyperterm_melphalan_dato2, xmmm_behandling_hyperterm_tnfalfa2, xmmm_behandling_hyperterm_tnfalfa_beskriv2, xmmm_behandling_hyperterm_tnfalfa_dato2, xmetastase_lunge2, xmetastase_lever2, xmetastase_milt2, xmetastase_binyre2, xmetastase_kutane2, xmetastase_subkutane2, xmetastase_knogle2, xmetastase_lymfeknude2, xmetastase_andet2, xmetastase_andet_beskriv2, xudbredning_verificeret2
	Dim sConnString2, objConn2, sSQL_update, sSQL1_update
	xusername2 = Request.Cookies("melanomcookie")("User")
	xpatient_id_onstudy22 = Request.Form("patient_id_onstudy22")
	xmmm_behandling_none2 = MM_IIF(Request.Form("mmm_behandling_none2"), 1, 0)
	xmmm_behandling_kirurgi2 = MM_IIF(Request.Form("mmm_behandling_kirurgi2"), 1, 0)
	xmmm_behandling_kirurgi_beskriv2 = Request.Form("mmm_behandling_kirurgi_beskriv2")
	xmmm_behandling_kirurgi_dato2 = MM_IIF(Request.Form("mmm_behandling_kirurgi_dato2"), Request.Form("mmm_behandling_kirurgi_dato2"), null)
	xmmm_behandling_radio2 = MM_IIF(Request.Form("mmm_behandling_radio2"), 1, 0)
	xmmm_behandling_radioterapi_beskriv2 = Request.Form("mmm_behandling_radioterapi_beskriv2")
	xmmm_behandling_radioterapi_dato2 = MM_IIF(Request.Form("mmm_behandling_radioterapi_dato2"), Request.Form("mmm_behandling_radioterapi_dato2"), null)
	xmmm_behandling_hyperterm_melphalan2 = MM_IIF(Request.Form("mmm_behandling_hyperterm_melphalan2"), 1, 0)
	xmmm_behandling_hyperterm_melphalan_beskriv2 = Request.Form("mmm_behandling_hyperterm_melphalan_beskriv2")
	xmmm_behandling_hyperterm_melphalan_dato2 = MM_IIF(Request.Form("mmm_behandling_hyperterm_melphalan_dato2"), Request.Form("mmm_behandling_hyperterm_melphalan_dato2"), null)
	xmmm_behandling_hyperterm_tnfalfa2 = MM_IIF(Request.Form("mmm_behandling_hyperterm_tnfalfa2"), 1, 0)
	xmmm_behandling_hyperterm_tnfalfa_beskriv2 = Request.Form("mmm_behandling_hyperterm_tnfalfa_beskriv2")
	xmmm_behandling_hyperterm_tnfalfa_dato2 = MM_IIF(Request.Form("mmm_behandling_hyperterm_tnfalfa_dato2"), Request.Form("mmm_behandling_hyperterm_tnfalfa_dato2"), null)
	xmetastase_lunge2 = MM_IIF(Request.Form("metastase_lunge2"), 1, 0)
	xmetastase_lever2 = MM_IIF(Request.Form("metastase_lever2"), 1, 0)
	xmetastase_milt2 = MM_IIF(Request.Form("metastase_milt2"), 1, 0)
	xmetastase_binyre2 = MM_IIF(Request.Form("metastase_binyre2"), 1, 0)
	xmetastase_kutane2 = MM_IIF(Request.Form("metastase_kutane2"), 1, 0)
	xmetastase_subkutane2 = MM_IIF(Request.Form("metastase_subkutane2"), 1, 0)
	xmetastase_knogle2 = MM_IIF(Request.Form("metastase_knogle2"), 1, 0)
	xmetastase_lymfeknude2 = MM_IIF(Request.Form("metastase_lymfeknude2"), 1, 0)
	xmetastase_andet2 = MM_IIF(Request.Form("metastase_andet2"), 1, 0)
	xmetastase_andet_beskriv2 = Request.Form("metastase_andet_beskriv2")
	xudbredning_verificeret2 = Request.Form("udbredning_verificeret2")
	xonstudy2_updateID = MM_IIF(Request.Form("MM_recordId"), Request.Form("MM_recordId"), null)
	sConnString2 = MM_conmelanom_STRING
	Set objConn2 = Server.CreateObject("ADODB.Connection")
	objConn2.Open(sConnString2) 
	sSQL_update = "UPDATE tbl_onstudy2 SET username = '" & xusername2 & "', mmm_behandling_none = '" & xmmm_behandling_none2 & "', mmm_behandling_kirurgi = '" & xmmm_behandling_kirurgi2 & "', mmm_behandling_kirurgi_beskriv = '" & xmmm_behandling_kirurgi_beskriv2 & "', mmm_behandling_kirurgi_dato = '" & xmmm_behandling_kirurgi_dato2 & "', mmm_behandling_radio = '" & xmmm_behandling_radio2 & "', mmm_behandling_radioterapi_beskriv = '" & xmmm_behandling_radioterapi_beskriv2 & "', mmm_behandling_radioterapi_dato = '" & xmmm_behandling_radioterapi_dato2 & "', mmm_behandling_hyperterm_melphalan = '" & xmmm_behandling_hyperterm_melphalan2 & "', mmm_behandling_hyperterm_melphalan_beskriv = '" & xmmm_behandling_hyperterm_melphalan_beskriv2 & "', mmm_behandling_hyperterm_melphalan_dato = '" & xmmm_behandling_hyperterm_melphalan_dato2 & "', mmm_behandling_hyperterm_tnfalfa = '" & xmmm_behandling_hyperterm_tnfalfa2 & "', mmm_behandling_hyperterm_tnfalfa_beskriv = '" & xmmm_behandling_hyperterm_tnfalfa_beskriv2 & "', mmm_behandling_hyperterm_tnfalfa_dato = '" & xmmm_behandling_hyperterm_tnfalfa_dato2 & "', metastase_lunge = '" & xmetastase_lunge2 & "', metastase_lever = '" & xmetastase_lever2 & "', metastase_milt = '" & xmetastase_milt2 & "', metastase_binyre = '" & xmetastase_binyre2 & "', metastase_kutane = '" & xmetastase_kutane2 & "', metastase_subkutane = '" & xmetastase_subkutane2 & "', metastase_knogle = '" & xmetastase_knogle2 & "', metastase_lymfeknude = '" & xmetastase_lymfeknude2 & "', metastase_andet = '" & xmetastase_andet2 & "', metastase_andet_beskriv = '" & xmetastase_andet_beskriv2 & "', udbredning_verificeret = '" & xudbredning_verificeret2 & "' WHERE onstudy2_id = '" & xonstudy2_updateID & "'"
	sSQL1_update = "INSERT INTO tbl_onstudy2_log (username, patient_id_onstudy2, mmm_behandling_none, mmm_behandling_kirurgi, mmm_behandling_kirurgi_beskriv, mmm_behandling_kirurgi_dato, mmm_behandling_radio, mmm_behandling_radioterapi_beskriv, mmm_behandling_radioterapi_dato, mmm_behandling_hyperterm_melphalan, mmm_behandling_hyperterm_melphalan_beskriv, mmm_behandling_hyperterm_melphalan_dato, mmm_behandling_hyperterm_tnfalfa, mmm_behandling_hyperterm_tnfalfa_beskriv, mmm_behandling_hyperterm_tnfalfa_dato, metastase_lunge, metastase_lever, metastase_milt, metastase_binyre, metastase_kutane, metastase_subkutane, metastase_knogle, metastase_lymfeknude, metastase_andet, metastase_andet_beskriv, udbredning_verificeret) VALUES ('" & xusername2 & "','" & xpatient_id_onstudy22 & "','" & xmmm_behandling_none2 & "','" & xmmm_behandling_kirurgi2 & "','" & xmmm_behandling_kirurgi_beskriv2 & "','" & xmmm_behandling_kirurgi_dato2 & "','" & xmmm_behandling_radio2 & "','" & xmmm_behandling_radioterapi_beskriv2 & "','" & xmmm_behandling_radioterapi_dato2 & "','" & xmmm_behandling_hyperterm_melphalan2 & "','" & xmmm_behandling_hyperterm_melphalan_beskriv2 & "','" & xmmm_behandling_hyperterm_melphalan_dato2 & "','" & xmmm_behandling_hyperterm_tnfalfa2 & "','" & xmmm_behandling_hyperterm_tnfalfa_beskriv2 & "','" & xmmm_behandling_hyperterm_tnfalfa_dato2 & "','" & xmetastase_lunge2 & "','" & xmetastase_lever2 & "','" & xmetastase_milt2 & "','" & xmetastase_binyre2 & "','" & xmetastase_kutane2 & "','" & xmetastase_subkutane2 & "','" & xmetastase_knogle2 & "','" & xmetastase_lymfeknude2 & "','" & xmetastase_andet2 & "','" & xmetastase_andet_beskriv2 & "','" & xudbredning_verificeret2 & "')"
	objConn2.execute(sSQL_update)
	objConn2.execute(sSQL1_update)
	objConn2.Close
	Set objConn2 = nothing

  End If
End If
%>
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("patient_id_onstudy2") <> "") Then 
  Recordset1__MMColParam = Request.QueryString("patient_id_onstudy2")
End If
%>
<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows

Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_conmelanom_STRING
Recordset1_cmd.CommandText = "SELECT * FROM tbl_onstudy2 WHERE patient_id_onstudy2 = ?" 
Recordset1_cmd.Prepared = true
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param1", 200, 1, 10, Recordset1__MMColParam) ' adVarChar

Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Melanom - On study II</title>
<link href="/melanom/oneColElsCtrHdr.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {
	font-size: 24px;
	font-weight: bold;
	color: #0000FF;
}
.style2 {
font-size: 18px;
color: #0000FF}
-->
</style>
<style type="text/css">
<!--
body {
	background-color: #FFFFFF;
}
.style31 {
	font-size: 9px
}
a:link {
	color: #000099;
}
a:visited {
	color: #000099;
}
.style32 {color: #000000}
.style33 {
	color: #FFFFFF;
	font-weight: bold;
}
.style34 {
	color: #FF0000;
	font-weight: bold;
}
.stylegreen {color: #090;
	font-weight:bold}
.stylered {
	color:#F00;
	font-weight:bold;
}
-->
</style>
</head>
<body class="oneColElsCtrHdr">
<%  
Session.LCID=1053
%>
<%if (Recordset1.EOF) THEN%>
<form action="<%=MM_editAction%>" method="post" name="form1" id="form1">
  <table border="0" cellpadding="0" cellspacing="0">
    <tr valign="baseline">
      <td align="right" nowrap="nowrap"><div align="left" class="style2">ON STUDY 2</div></td>
      <td colspan="3">&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td width="443" align="right" nowrap="nowrap">Patientkode:</td>
      <td colspan="3"><input type="hidden" name="patient_id_onstudy2" value="<%=(Request.QueryString("patient_id_onstudy2"))%>" size="32" />        &nbsp;&nbsp;<%=(Request.QueryString("patient_id_onstudy2"))%> </td>
    </tr>
    <tr valign="baseline">
      <td colspan="4" nowrap="nowrap">1.	Tidligere behandling for MMM (M1-sygdom) (+ angivelse af tidspunkt, samt at der jo kan være brugt flere af modaliteterne):</td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Ingen:</td>
      <td width="35"><input type="checkbox" name="mmm_behandling_none" value="1" />      </td>
      <td width="476">&nbsp;</td>
      <td width="82">&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Kirurgi:</td>
      <td><input type="checkbox" name="mmm_behandling_kirurgi" value="1" />      </td>
      <td><input type="text" name="mmm_behandling_kirurgi_beskriv" value="" size="75" /></td>
      <td><input type="text" name="mmm_behandling_kirurgi_dato" value="" size="12" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Radioterapi:</td>
      <td><input type="checkbox" name="mmm_behandling_radio" value="1" />      </td>
      <td><input type="text" name="mmm_behandling_radioterapi_beskriv" value="" size="75" /></td>
      <td><input type="text" name="mmm_behandling_radioterapi_dato" value="" size="12" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Hyperterm Regional Perfusion (Melphalan):</td>
      <td><input type="checkbox" name="mmm_behandling_hyperterm_melphalan" value="1" />      </td>
      <td><input type="text" name="mmm_behandling_hyperterm_melphalan_beskriv" value="" size="75" /></td>
      <td><input type="text" name="mmm_behandling_hyperterm_melphalan_dato" value="" size="12" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Hyperterm Regional Perfusion (TNF-alfa) :</td>
      <td><input type="checkbox" name="mmm_behandling_hyperterm_tnfalfa" value="1" />      </td>
      <td><input type="text" name="mmm_behandling_hyperterm_tnfalfa_beskriv" value="" size="75" /></td>
      <td><input type="text" name="mmm_behandling_hyperterm_tnfalfa_dato" value="" size="12" /></td>
    </tr>
    <tr valign="baseline">
      <td colspan="4" nowrap="nowrap">2.	Aktuelle sygdomsudbredning (afkryds alle der gælder):</td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Lunge metastaser:</td>
      <td><input type="checkbox" name="metastase_lunge" value="1" />      </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Lever metastaser:</td>
      <td><input type="checkbox" name="metastase_lever" value="1" />      </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Milt metastaser:</td>
      <td><input type="checkbox" name="metastase_milt" value="1" />      </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Binyre metastaser:</td>
      <td><input type="checkbox" name="metastase_binyre" value="1" />      </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Kutane metastaser:</td>
      <td><input type="checkbox" name="metastase_kutane" value="1" />      </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Subkutane metastaser:</td>
      <td><input type="checkbox" name="metastase_subkutane" value="1" />      </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Knogle metastaser:</td>
      <td><input type="checkbox" name="metastase_knogle" value="1" />      </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Lymfeknude metastaser:</td>
      <td><input type="checkbox" name="metastase_lymfeknude" value="1" />      </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Andet:</td>
      <td><input type="checkbox" name="metastase_andet" value="1" />      </td>
      <td><input type="text" name="metastase_andet_beskriv" value="" size="75" /></td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">3.	Aktuelle sygdomsudbredning bioptisk verificeret:</td>
      <td colspan="3"><select name="udbredning_verificeret" id="udbredning_verificeret">
                <option value="na" selected="selected"></option>
                <option value="yes">yes</option>
                <option value="no">no</option>
      </select></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">&nbsp;</td>
      <td>&nbsp;</td>
      <td><input type="submit" class="stylegreen" value="Gem" /></td>
      <td>&nbsp;</td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1" />
</form>
<p>&nbsp;</p>
<%Else%>
<form action="<%=MM_editAction%>" method="post" name="form2" id="form2">
  <table border="0" cellpadding="0" cellspacing="0">
    <tr valign="baseline">
      <td nowrap="nowrap" align="right"><div align="left"><span class="style2">ON STUDY 2</span></div></td>
      <td colspan="3">&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Patientkode:</td>
      <td colspan="3"><input type="hidden" name="patient_id_onstudy22" value="<%=(Request.QueryString("patient_id_onstudy2"))%>" size="32" />
&nbsp;&nbsp;<%=(Request.QueryString("patient_id_onstudy2"))%> </td>
    </tr>
    <tr valign="baseline">
      <td colspan="4" align="right" nowrap="nowrap"><div align="left">1.	Tidligere behandling for MMM (M1-sygdom) (+ angivelse af tidspunkt, samt at der jo kan være brugt flere af modaliteterne):</div></td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right"><input type="hidden" name="onstudy2_id" value="<%=(Recordset1.Fields.Item("onstudy2_id").Value)%>" size="32" />
      Ingen:</td>
      <td><input <%If (CStr((Recordset1.Fields.Item("mmm_behandling_none").Value)) = CStr("1")) Then Response.Write("checked=""checked""") : Response.Write("")%> type="checkbox" name="mmm_behandling_none2" value="1" /></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap">Kirurgi:</td>
      <td><input <%If (CStr((Recordset1.Fields.Item("mmm_behandling_kirurgi").Value)) = CStr("1")) Then Response.Write("checked=""checked""") : Response.Write("")%> type="checkbox" name="mmm_behandling_kirurgi2" value="1" /></td>
      <td><input type="text" name="mmm_behandling_kirurgi_beskriv2" value="<%=(Recordset1.Fields.Item("mmm_behandling_kirurgi_beskriv").Value)%>" size="75" /></td>
      <td><input type="text" name="mmm_behandling_kirurgi_dato2" value="<%=(Recordset1.Fields.Item("mmm_behandling_kirurgi_dato").Value)%>" size="10" /></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap">Radioterapi:</td>
      <td><input <%If (CStr((Recordset1.Fields.Item("mmm_behandling_radio").Value)) = CStr("1")) Then Response.Write("checked=""checked""") : Response.Write("")%> type="checkbox" name="mmm_behandling_radio2" value="1" />      </td>
      <td><input type="text" name="mmm_behandling_radioterapi_beskriv2" value="<%=(Recordset1.Fields.Item("mmm_behandling_radioterapi_beskriv").Value)%>" size="75" /></td>
      <td><input type="text" name="mmm_behandling_radioterapi_dato2" value="<%=(Recordset1.Fields.Item("mmm_behandling_radioterapi_dato").Value)%>" size="10" /></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap">Hyperterm Regional Perfusion (Melphalan):</td>
      <td><input <%If (CStr((Recordset1.Fields.Item("mmm_behandling_hyperterm_melphalan").Value)) = CStr("1")) Then Response.Write("checked=""checked""") : Response.Write("")%> type="checkbox" name="mmm_behandling_hyperterm_melphalan2" value="1" />      </td>
      <td><input type="text" name="mmm_behandling_hyperterm_melphalan_beskriv2" value="<%=(Recordset1.Fields.Item("mmm_behandling_hyperterm_melphalan_beskriv").Value)%>" size="75" /></td>
      <td><input type="text" name="mmm_behandling_hyperterm_melphalan_dato2" value="<%=(Recordset1.Fields.Item("mmm_behandling_hyperterm_melphalan_dato").Value)%>" size="10" /></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap">Hyperterm Regional Perfusion (TNF-alfa) :</td>
      <td><input <%If (CStr((Recordset1.Fields.Item("mmm_behandling_hyperterm_tnfalfa").Value)) = CStr("1")) Then Response.Write("checked=""checked""") : Response.Write("")%> type="checkbox" name="mmm_behandling_hyperterm_tnfalfa2" value="1" />      </td>
      <td><input type="text" name="mmm_behandling_hyperterm_tnfalfa_beskriv2" value="<%=(Recordset1.Fields.Item("mmm_behandling_hyperterm_tnfalfa_beskriv").Value)%>" size="75" /></td>
      <td><input type="text" name="mmm_behandling_hyperterm_tnfalfa_dato2" value="<%=(Recordset1.Fields.Item("mmm_behandling_hyperterm_tnfalfa_dato").Value)%>" size="10" /></td>
    </tr>
    <tr valign="baseline">
      <td colspan="4" align="right" nowrap="nowrap"><div align="left">2.	Aktuelle sygdomsudbredning (afkryds alle der gælder):</div></td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap">Lunge metastaser:</td>
      <td><input <%If (CStr((Recordset1.Fields.Item("metastase_lunge").Value)) = CStr("1")) Then Response.Write("checked=""checked""") : Response.Write("")%> type="checkbox" name="metastase_lunge2" value="1" />      </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap">Lever metastaser:</td>
      <td><input <%If (CStr((Recordset1.Fields.Item("metastase_lever").Value)) = CStr("1")) Then Response.Write("checked=""checked""") : Response.Write("")%> type="checkbox" name="metastase_lever2" value="1" />      </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap">Milt metastaser:</td>
      <td><input <%If (CStr((Recordset1.Fields.Item("metastase_milt").Value)) = CStr("1")) Then Response.Write("checked=""checked""") : Response.Write("")%> type="checkbox" name="metastase_milt2" value="1" />      </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap">Binyre metastaser:</td>
      <td><input <%If (CStr((Recordset1.Fields.Item("metastase_binyre").Value)) = CStr("1")) Then Response.Write("checked=""checked""") : Response.Write("")%> type="checkbox" name="metastase_binyre2" value="1" />      </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap">Kutane metastaser:</td>
      <td><input <%If (CStr((Recordset1.Fields.Item("metastase_kutane").Value)) = CStr("1")) Then Response.Write("checked=""checked""") : Response.Write("")%> type="checkbox" name="metastase_kutane2" value="1" />      </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap">Subkutane metastaser:</td>
      <td><input <%If (CStr((Recordset1.Fields.Item("metastase_subkutane").Value)) = CStr("1")) Then Response.Write("checked=""checked""") : Response.Write("")%> type="checkbox" name="metastase_subkutane2" value="1" />      </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap">Knogle metastaser:</td>
      <td><input <%If (CStr((Recordset1.Fields.Item("metastase_knogle").Value)) = CStr("1")) Then Response.Write("checked=""checked""") : Response.Write("")%> type="checkbox" name="metastase_knogle2" value="1" /></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap">Lymfeknude metastaser:</td>
      <td><input <%If (CStr((Recordset1.Fields.Item("metastase_lymfeknude").Value)) = CStr("1")) Then Response.Write("checked=""checked""") : Response.Write("")%> type="checkbox" name="metastase_lymfeknude2" value="1" />      </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap">Andet:</td>
      <td><input <%If (CStr((Recordset1.Fields.Item("metastase_andet").Value)) = CStr("1")) Then Response.Write("checked=""checked""") : Response.Write("")%> type="checkbox" name="metastase_andet2" value="1" />      </td>
      <td><input type="text" name="metastase_andet_beskriv2" value="<%=(Recordset1.Fields.Item("metastase_andet_beskriv").Value)%>" size="75" /></td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td align="right" nowrap="nowrap">3.	Aktuelle sygdomsudbredning bioptisk verificeret:</td>
      <td><select name="udbredning_verificeret2" id="udbredning_verificeret2">
                <option value="na" <%If (Not isNull(Recordset1.Fields.Item("udbredning_verificeret").Value)) Then If ("na" = CStr(Recordset1.Fields.Item("udbredning_verificeret").Value)) Then Response.Write("selected='selected'") : Response.Write("")%>></option>
                <option value="yes" <%If (Not isNull(Recordset1.Fields.Item("udbredning_verificeret").Value)) Then If ("yes" = CStr(Recordset1.Fields.Item("udbredning_verificeret").Value)) Then Response.Write("selected='selected'") : Response.Write("")%>>yes</option>
                <option value="no"<%If (Not isNull(Recordset1.Fields.Item("udbredning_verificeret").Value)) Then If ("no" = CStr(Recordset1.Fields.Item("udbredning_verificeret").Value)) Then Response.Write("selected='selected'") : Response.Write("")%>>no</option>
      </select></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">&nbsp;</td>
      <td>&nbsp;</td>
      <td><input type="submit" class="stylegreen" value="Opdater" /></td>
      <td>&nbsp;</td>
    </tr>
  </table>
  <input type="hidden" name="MM_update" value="form2" />
  <input type="hidden" name="MM_recordId" value="<%= Recordset1.Fields.Item("onstudy2_id").Value %>" />
</form>
<%End If%>
<p>&nbsp;</p>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>

Open in new window

MySQL ServerASP

Avatar of undefined
Last Comment
ullenulle

8/22/2022 - Mon
Steve Tempest

Does the column allow NULL?

Also you could test to see if the value in the post data is null and then alter your update or insert statement?

Please run the following command on the mysql console and send post the result.

SHOW CREATE TABLE tbl_onstudy2\G
ullenulle

ASKER
Hi. Thanks for your response. I ran your command, and this is the result:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\G' at line 1

I guess you expected something else? :o)

Yes, I allow NULL for all date-variables. When I create a new record and I entered a date for all date-variables, then it works fine. But if some or all is empty, then I get the error. Also if I make a date-variable empty in an existing date-variable, then I get the error.
When I create or edit records in phpmyadmin (the console), then I can do anything I want to. And if I remove the date-variables in the SQL-codes, then no problems either... It's something with those stupid date-variables...

Best regards

Ullenulle
Steve Tempest

Hi,

If the value in the form is empty try making the value 'NULL' instead of just blank...

Can you print the update statement to the screen and paste here for me so we can try a few things?

Also try running that command again without the \G on the end of it...

Cheers
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
ullenulle

ASKER
Here's your command:

CREATE TABLE `tbl_onstudy2` (
 `onstudy2_id` int(11) NOT NULL auto_increment,
 `username` varchar(30) collate latin1_danish_ci NOT NULL,
 `regidate` timestamp NOT NULL default CURRENT_TIMESTAMP,
 `patient_id_onstudy2` varchar(10) collate latin1_danish_ci NOT NULL,
 `mmm_behandling_none` tinyint(4) NOT NULL,
 `mmm_behandling_kirurgi` tinyint(4) NOT NULL,
 `mmm_behandling_kirurgi_beskriv` varchar(255) collate latin1_danish_ci NOT NULL,
 `mmm_behandling_kirurgi_dato` date default NULL,
 `mmm_behandling_radio` tinyint(4) NOT NULL,
 `mmm_behandling_radioterapi_beskriv` varchar(255) collate latin1_danish_ci NOT NULL,
 `mmm_behandling_radioterapi_dato` date default NULL,
 `mmm_behandling_hyperterm_melphalan` tinyint(4) NOT NULL,
 `mmm_behandling_hyperterm_melphalan_beskriv` varchar(255) collate latin1_danish_ci NOT NULL,
 `mmm_behandling_hyperterm_melphalan_dato` date default NULL,
 `mmm_behandling_hyperterm_tnfalfa` tinyint(4) NOT NULL,
 `mmm_behandling_hyperterm_tnfalfa_beskriv` varchar(255) collate latin1_danish_ci NOT NULL,
 `mmm_behandling_hyperterm_tnfalfa_dato` date default NULL,
 `metastase_lunge` tinyint(4) NOT NULL,
 `metastase_lever` tinyint(4) NOT NULL,
 `metastase_milt` tinyint(4) NOT NULL,
 `metastase_binyre` tinyint(4) NOT NULL,
 `metastase_kutane` tinyint(4) NOT NULL,
 `metastase_subkutane` tinyint(4) NOT NULL,
 `metastase_knogle` tinyint(4) NOT NULL,
 `metastase_lymfeknude` tinyint(4) NOT NULL,
 `metastase_andet` tinyint(4) NOT NULL,
 `metastase_andet_beskriv` varchar(255) collate latin1_danish_ci NOT NULL,
 `udbredning_verificeret` varchar(3) collate latin1_danish_ci NOT NULL,
 PRIMARY KEY  (`onstudy2_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 COLLATE=latin1_danish_ci

About empty vs. NULL... Note my SQL-code for the date-fields:

xmmm_behandling_kirurgi_dato = MM_IIF(Request.Form("mmm_behandling_kirurgi_dato"), Request.Form("mmm_behandling_kirurgi_dato"), null)

If the field is empty, then it will enter "NULL" into the table. It worked fine so far in other of my databases, but for some reason not now... :-(
Can't you see all the code in my page? I added it to this question. The SQL UPDATE statement is line 137.

Best regards

Ullenulle
Steve Tempest

Can you send me the update statement that fails please? So that I can see exactly what is passed to the ODBC... I don't have an ASP server to test your code on. And yes I've read line 137.

ullenulle

ASKER
Hi again.

This is the UPDATE-statement, that fails when a date-value isn't entered:

sSQL_update = "UPDATE tbl_onstudy2 SET username = '" & xusername2 & "', mmm_behandling_none = '" & xmmm_behandling_none2 & "', mmm_behandling_kirurgi = '" & xmmm_behandling_kirurgi2 & "', mmm_behandling_kirurgi_beskriv = '" & xmmm_behandling_kirurgi_beskriv2 & "', mmm_behandling_kirurgi_dato = '" & xmmm_behandling_kirurgi_dato2 & "', mmm_behandling_radio = '" & xmmm_behandling_radio2 & "', mmm_behandling_radioterapi_beskriv = '" & xmmm_behandling_radioterapi_beskriv2 & "', mmm_behandling_radioterapi_dato = '" & xmmm_behandling_radioterapi_dato2 & "', mmm_behandling_hyperterm_melphalan = '" & xmmm_behandling_hyperterm_melphalan2 & "', mmm_behandling_hyperterm_melphalan_beskriv = '" & xmmm_behandling_hyperterm_melphalan_beskriv2 & "', mmm_behandling_hyperterm_melphalan_dato = '" & xmmm_behandling_hyperterm_melphalan_dato2 & "', mmm_behandling_hyperterm_tnfalfa = '" & xmmm_behandling_hyperterm_tnfalfa2 & "', mmm_behandling_hyperterm_tnfalfa_beskriv = '" & xmmm_behandling_hyperterm_tnfalfa_beskriv2 & "', mmm_behandling_hyperterm_tnfalfa_dato = '" & xmmm_behandling_hyperterm_tnfalfa_dato2 & "', metastase_lunge = '" & xmetastase_lunge2 & "', metastase_lever = '" & xmetastase_lever2 & "', metastase_milt = '" & xmetastase_milt2 & "', metastase_binyre = '" & xmetastase_binyre2 & "', metastase_kutane = '" & xmetastase_kutane2 & "', metastase_subkutane = '" & xmetastase_subkutane2 & "', metastase_knogle = '" & xmetastase_knogle2 & "', metastase_lymfeknude = '" & xmetastase_lymfeknude2 & "', metastase_andet = '" & xmetastase_andet2 & "', metastase_andet_beskriv = '" & xmetastase_andet_beskriv2 & "', udbredning_verificeret = '" & xudbredning_verificeret2 & "' WHERE onstudy2_id = '" & xonstudy2_updateID & "'"

And here's the INSERT statement that fails, when a date-value is missing:

sSQL = "INSERT INTO tbl_onstudy2 (username, patient_id_onstudy2, mmm_behandling_none, mmm_behandling_kirurgi, mmm_behandling_kirurgi_beskriv, mmm_behandling_kirurgi_dato, mmm_behandling_radio, mmm_behandling_radioterapi_beskriv, mmm_behandling_radioterapi_dato, mmm_behandling_hyperterm_melphalan, mmm_behandling_hyperterm_melphalan_beskriv, mmm_behandling_hyperterm_melphalan_dato, mmm_behandling_hyperterm_tnfalfa, mmm_behandling_hyperterm_tnfalfa_beskriv, mmm_behandling_hyperterm_tnfalfa_dato, metastase_lunge, metastase_lever, metastase_milt, metastase_binyre, metastase_kutane, metastase_subkutane, metastase_knogle, metastase_lymfeknude, metastase_andet, metastase_andet_beskriv, udbredning_verificeret) VALUES ('" & xusername & "','" & xpatient_id_onstudy2 & "','" & xmmm_behandling_none & "','" & xmmm_behandling_kirurgi & "','" & xmmm_behandling_kirurgi_beskriv & "','" & xmmm_behandling_kirurgi_dato & "','" & xmmm_behandling_radio & "','" & xmmm_behandling_radioterapi_beskriv & "','" & xmmm_behandling_radioterapi_dato & "','" & xmmm_behandling_hyperterm_melphalan & "','" & xmmm_behandling_hyperterm_melphalan_beskriv & "','" & xmmm_behandling_hyperterm_melphalan_dato & "','" & xmmm_behandling_hyperterm_tnfalfa & "','" & xmmm_behandling_hyperterm_tnfalfa_beskriv & "','" & xmmm_behandling_hyperterm_tnfalfa_dato & "','" & xmetastase_lunge & "','" & xmetastase_lever & "','" & xmetastase_milt & "','" & xmetastase_binyre & "','" & xmetastase_kutane & "','" & xmetastase_subkutane & "','" & xmetastase_knogle & "','" & xmetastase_lymfeknude & "','" & xmetastase_andet & "','" & xmetastase_andet_beskriv & "','" & xudbredning_verificeret & "')"

Best regards

Ullenulle
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Steve Tempest

in your asp can you set it so that before it executes the insert and update it prints the value of
sSQL_update and sSQL to the page and copy and paste that...

So you go in and alter the form and then hit submit and have it print the update statement to the screen and paste that here... as everything in the above example is empty.

The reason I ask is that I have setup your table in my database and I'd like to try the exact same update statement that you are passing to the ODBC on the mysql console.

So if you can provide a fully populated insert statement and then an update statement that updates the insert that would be good.

In your error message it says

Incorrect date value: '' for column mmm_behandling_hyperterm_tnfalfa_dato

and if the value of mmm_behandling_hyperterm_tnfalfa_dato is 'NULL' (type string)

The error would read

Incorrect date value: 'NULL' for column mmm_behandling_hyperterm_tnfalfa_dato
ullenulle

ASKER
Hi again.

Ok... I made a response.write before the code is executed. INSERT-error first:

INSERT INTO tbl_onstudy2 (username, patient_id_onstudy2, mmm_behandling_none, mmm_behandling_kirurgi, mmm_behandling_kirurgi_beskriv, mmm_behandling_kirurgi_dato, mmm_behandling_radio, mmm_behandling_radioterapi_beskriv, mmm_behandling_radioterapi_dato, mmm_behandling_hyperterm_melphalan, mmm_behandling_hyperterm_melphalan_beskriv, mmm_behandling_hyperterm_melphalan_dato, mmm_behandling_hyperterm_tnfalfa, mmm_behandling_hyperterm_tnfalfa_beskriv, mmm_behandling_hyperterm_tnfalfa_dato, metastase_lunge, metastase_lever, metastase_milt, metastase_binyre, metastase_kutane, metastase_subkutane, metastase_knogle, metastase_lymfeknude, metastase_andet, metastase_andet_beskriv, udbredning_verificeret) VALUES ('uhk','112342','1','0','','','0','','','0','','','0','','','0','0','0','0','0','0','0','0','0','','na')INSERT INTO tbl_onstudy2_log (username, patient_id_onstudy2, mmm_behandling_none, mmm_behandling_kirurgi, mmm_behandling_kirurgi_beskriv, mmm_behandling_kirurgi_dato, mmm_behandling_radio, mmm_behandling_radioterapi_beskriv, mmm_behandling_radioterapi_dato, mmm_behandling_hyperterm_melphalan, mmm_behandling_hyperterm_melphalan_beskriv, mmm_behandling_hyperterm_melphalan_dato, mmm_behandling_hyperterm_tnfalfa, mmm_behandling_hyperterm_tnfalfa_beskriv, mmm_behandling_hyperterm_tnfalfa_dato, metastase_lunge, metastase_lever, metastase_milt, metastase_binyre, metastase_kutane, metastase_subkutane, metastase_knogle, metastase_lymfeknude, metastase_andet, metastase_andet_beskriv, udbredning_verificeret) VALUES ('uhk','112342','1','0','','','0','','','0','','','0','','','0','0','0','0','0','0','0','0','0','','na')
Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[MySQL][ODBC 5.1 Driver][mysqld-5.0.51b-community-nt]Incorrect date value: '' for column 'mmm_behandling_kirurgi_dato' at row 1

/melanom/melanom_onstudy2.asp, line 94


... and UPDATE-error:

UPDATE tbl_onstudy2 SET username = 'uhk', mmm_behandling_none = '1', mmm_behandling_kirurgi = '0', mmm_behandling_kirurgi_beskriv = 'test', mmm_behandling_kirurgi_dato = '2010-08-10', mmm_behandling_radio = '0', mmm_behandling_radioterapi_beskriv = 'test', mmm_behandling_radioterapi_dato = '2029-08-10', mmm_behandling_hyperterm_melphalan = '0', mmm_behandling_hyperterm_melphalan_beskriv = 'test', mmm_behandling_hyperterm_melphalan_dato = '2010-10-19', mmm_behandling_hyperterm_tnfalfa = '0', mmm_behandling_hyperterm_tnfalfa_beskriv = 'test', mmm_behandling_hyperterm_tnfalfa_dato = '', metastase_lunge = '0', metastase_lever = '0', metastase_milt = '0', metastase_binyre = '0', metastase_kutane = '0', metastase_subkutane = '0', metastase_knogle = '0', metastase_lymfeknude = '0', metastase_andet = '0', metastase_andet_beskriv = 'test', udbredning_verificeret = 'yes' WHERE onstudy2_id = '1'INSERT INTO tbl_onstudy2_log (username, patient_id_onstudy2, mmm_behandling_none, mmm_behandling_kirurgi, mmm_behandling_kirurgi_beskriv, mmm_behandling_kirurgi_dato, mmm_behandling_radio, mmm_behandling_radioterapi_beskriv, mmm_behandling_radioterapi_dato, mmm_behandling_hyperterm_melphalan, mmm_behandling_hyperterm_melphalan_beskriv, mmm_behandling_hyperterm_melphalan_dato, mmm_behandling_hyperterm_tnfalfa, mmm_behandling_hyperterm_tnfalfa_beskriv, mmm_behandling_hyperterm_tnfalfa_dato, metastase_lunge, metastase_lever, metastase_milt, metastase_binyre, metastase_kutane, metastase_subkutane, metastase_knogle, metastase_lymfeknude, metastase_andet, metastase_andet_beskriv, udbredning_verificeret) VALUES ('uhk','112341','1','0','test','2010-08-10','0','test','2029-08-10','0','test','2010-10-19','0','test','','0','0','0','0','0','0','0','0','0','test','yes')
Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[MySQL][ODBC 5.1 Driver][mysqld-5.0.51b-community-nt]Incorrect date value: '' for column 'mmm_behandling_hyperterm_tnfalfa_dato' at row 1

/melanom/melanom_onstudy2.asp, line 143


Is that what you're looking for?

Best regards

Ullenulle
ullenulle

ASKER
Aha... I read the response.write now for the first time. :o)  It seems that the problem is, that my asp-code doesn't pass the "NULL" on to the database... do you agree??
Let's take for example this date-field:

xmmm_behandling_hyperterm_tnfalfa_dato = MM_IIF(Request.Form("mmm_behandling_hyperterm_tnfalfa_dato"), Request.Form("mmm_behandling_hyperterm_tnfalfa_dato"), null)

How should I make it different to pass the NULL on to the database in stead of an empty '' ? And how comes it's a problem now even though I used this code many times before with no problem??

Best regards

Ullenulle
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Steve Tempest

xmmm_behandling_kirurgi_dato = MM_IIF(Request.Form("mmm_behandling_kirurgi_dato"), Request.Form("mmm_behandling_kirurgi_dato"), "NULL")


Try altering your asp so that NULL is double quoted.

Also what version of mysql is the server?
Steve Tempest

both of those insert and update statements worked for me using the console... so I'm wondering if it's something to do with the ODBC where it doesn't like the values being empty....
Steve Tempest

your update would look like this.

UPDATE tbl_onstudy2 SET username = 'uhk', mmm_behandling_none = '1', mmm_behandling_kirurgi = '0', mmm_behandling_kirurgi_beskriv = 'test', mmm_behandling_kirurgi_dato = '2010-08-10', mmm_behandling_radio = '0', mmm_behandling_radioterapi_beskriv = 'test', mmm_behandling_radioterapi_dato = '2029-08-10', mmm_behandling_hyperterm_melphalan = '0', mmm_behandling_hyperterm_melphalan_beskriv = 'test', mmm_behandling_hyperterm_melphalan_dato = '2010-10-19', mmm_behandling_hyperterm_tnfalfa = '0', mmm_behandling_hyperterm_tnfalfa_beskriv = 'test', mmm_behandling_hyperterm_tnfalfa_dato = 'NULL', metastase_lunge = '0', metastase_lever = '0', metastase_milt = '0', metastase_binyre = '0', metastase_kutane = '0', metastase_subkutane = '0', metastase_knogle = '0', metastase_lymfeknude = '0', metastase_andet = '0', metastase_andet_beskriv = 'test', udbredning_verificeret = 'yes' WHERE onstudy2_id = '1'
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ullenulle

ASKER
Double-quoting doesn't help... The response.write still looks like this:

UPDATE tbl_onstudy2 SET username = 'uhk', mmm_behandling_none = '1', mmm_behandling_kirurgi = '0', mmm_behandling_kirurgi_beskriv = 'test', mmm_behandling_kirurgi_dato = '2010-08-10', mmm_behandling_radio = '0', mmm_behandling_radioterapi_beskriv = 'test', mmm_behandling_radioterapi_dato = '2029-08-10', mmm_behandling_hyperterm_melphalan = '0', mmm_behandling_hyperterm_melphalan_beskriv = 'test', mmm_behandling_hyperterm_melphalan_dato = '2010-10-19', mmm_behandling_hyperterm_tnfalfa = '0', mmm_behandling_hyperterm_tnfalfa_beskriv = 'test', mmm_behandling_hyperterm_tnfalfa_dato = '', metastase_lunge = '0', metastase_lever = '0', metastase_milt = '0', metastase_binyre = '0', metastase_kutane = '0', metastase_subkutane = '0', metastase_knogle = '0', metastase_lymfeknude = '0', metastase_andet = '0', metastase_andet_beskriv = 'test', udbredning_verificeret = 'yes' WHERE onstudy2_id = '1'INSERT INTO tbl_onstudy2_log (username, patient_id_onstudy2, mmm_behandling_none, mmm_behandling_kirurgi, mmm_behandling_kirurgi_beskriv, mmm_behandling_kirurgi_dato, mmm_behandling_radio, mmm_behandling_radioterapi_beskriv, mmm_behandling_radioterapi_dato, mmm_behandling_hyperterm_melphalan, mmm_behandling_hyperterm_melphalan_beskriv, mmm_behandling_hyperterm_melphalan_dato, mmm_behandling_hyperterm_tnfalfa, mmm_behandling_hyperterm_tnfalfa_beskriv, mmm_behandling_hyperterm_tnfalfa_dato, metastase_lunge, metastase_lever, metastase_milt, metastase_binyre, metastase_kutane, metastase_subkutane, metastase_knogle, metastase_lymfeknude, metastase_andet, metastase_andet_beskriv, udbredning_verificeret) VALUES ('uhk','112341','1','0','test','2010-08-10','0','test','2029-08-10','0','test','2010-10-19','0','test','','0','0','0','0','0','0','0','0','0','test','yes')
Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[MySQL][ODBC 5.1 Driver][mysqld-5.0.51b-community-nt]Incorrect date value: '' for column 'mmm_behandling_hyperterm_tnfalfa_dato' at row 1

/melanom/melanom_onstudy2.asp, line 143


I even tried changing the date-variable like this:

xmmm_behandling_hyperterm_tnfalfa_dato2 = MM_IIF(Request.Form("mmm_behandling_hyperterm_tnfalfa_dato2")<>"", Request.Form("mmm_behandling_hyperterm_tnfalfa_dato2"), "null")

I thought that maybe asp suddenly evaluated an empty field as if there's a value... but no change...
It's MySQL 5.1 (Serverversion: 5.0.51b-community-nt). In my connectionstring I have:  DRIVER={MySQL ODBC 5.1 Driver}  and it works fine with all other databases of mine. I tried changing to 3.51, but the problem is still there... This is just too weird!!!! any other ideas?? :-)

Best regards

Ullenulle
Steve Tempest

Well, I would try hard coding the insert and update statements with the NULL in place and see if it works... then we just need to work out how to swap out the variable... with null it should not be quoted at all... the example above I posted is wrong as I have it single quoted.

if NULL wont work try '0000-00-00' instead from what I've read the ODBC will swap it out with NULL on execution.

https://www.experts-exchange.com/questions/22743297/Need-to-insert-null-into-date-field.html

I just found this post also... which confirm to me that it's likely that we need the word NULL and not empty single quotes...

ullenulle

ASKER
Ok... do we agree that I need to edit the date-variables before they are being passed on to the database? But asp takes single-quotes as a remark... How should I try the 0000-00-00 regarding quotes? I actually tried it a while ago without quotes and with double quotes. Any tricks?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Steve Tempest

Yes you need to check the variables and ensure they have a value. Is it possible to set the default value of the date input to 0000-00-00 so if not selected by the user then it will pass that value?

alternatively you would need to test if the date-variables are indeed valid and if not set the variable to 0000-00-00.

In the insert and update statement the 0000-00-00 needs to be single quoted like you have done for the other dates.

Sorry I'm not familiar with asp at all so cant be a huge help there... above is what I would do in perl...

Maybe try an if statement (i'm guessing so this code probably wont work...)

dato2 = Request.Form("mmm_behandling_hyperterm_tnfalfa_dato2")
dato2_len = len(dato2)
If(dato2_len == 0) Then
xmmm_behandling_kirurgi_dato2="0000-00-00"
Else
xmmm_behandling_kirurgi_dato2=dato2
End If
ullenulle

ASKER
I'll try to create some other code for the asp-part of the page. What's your conclusion? Is it an asp or MySQL problem? So far I guess it's more a problem with asp and/or the webserver... or the way my code is dealt with on the server. The "fun" part is, that it worked in other of my databases so far... so weird....
Steve Tempest

I think it could be a limitation of the version of the ODBC you are using. You could try updating it to a newer version. The reason I think this is that the sql you provided above with the single empty sql quotes executes on my mysql database just fine from the mysql console.

Version ODBC 5.1.8 is available and could be worth a try.
http://dev.mysql.com/downloads/connector/odbc/5.1.html

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ullenulle

ASKER
Hi again.

Hmmm... doesn't the ODBC version in my connectionstring refer to the database-server on my webhotel? If I update the ODBC, wouldn't that only affect my own computer?

Best regards

Ullenulle
ASKER CERTIFIED SOLUTION
Steve Tempest

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ullenulle

ASKER
I'll dig into that tomorrow. I'm away for a day. :-)

Best regards

Ullenulle
ullenulle

ASKER
Hey! Thank you so much! This was the solution to my annoying problem! My webhotel gave the user I created some "SUPER privilege". After that I was able to use this setting in my SQL-codes before executing any INSERT og UPDATE statements:
sessionSQL = "SET SESSION sql_mode = 'ALLOW_INVALID_DATES'"
objConn.execute(sessionSQL)

So finally my database will "eat" NULL in the date-fields. I just can't understand that the problem didn't occur untill now... weird... but main thing is that it works again now! Thank you again for guiding me in the right direction. :-)

Best regards

Ullenulle
Your help has saved me hundreds of hours of internet surfing.
fblack61