Forums

ASP

This topic is locked

Multiline update with Date fields

Posted 26 Apr 2008 22:31:38
1
has voted
26 Apr 2008 22:31:38 Carlos Rey posted:
Hi All!

Ok I am very new to this......

I am trying to update mulitple lines under one update (the field value may differ from line line). I found from DrDev a multliline update that works perfectly! you can find the original code as at www.drdev.net/article11.asp

This code update all fields of a praticular line with the values displayed, even if they are blank.

The probelem is that one of my fields is a date field. It does not accpet blanck fileds, It returns
<i><b>Microsoft OLE DB Provider for ODBC Drivers error '80040e07' </b></i>

I modified the code to make it work in my application. This code works if the field is not blank:
<pre id=code><font face=courier size=2 id=code>
&lt;%
If Request("Submit" &lt;&gt; "" Then
intRecIDs = Replace(Request("hidRecIDs", "*", "" ' remove all the asterisks, to create a list like this: 2, 5, 8, 9 etc.
arrRecIDs = Split(intRecIDs, ", " ' Create an array, wich will contain just the IDs of the records we need to update
For i = 0 to Ubound(arrRecIDs) ' Loop trough the array
dateDue = Replace(Request("txtDue" & arrRecIDs(i)), "'", "''"
strStat = Replace(Request("txtStat" & arrRecIDs(i)), "'", "''"
set commUpdate = Server.CreateObject("ADODB.Command"
commUpdate.ActiveConnection = MM_DataQCDB_STRING
commUpdate.CommandText = "UPDATE M_Schedule SET DDateCompleted ='" & dateDue & "',
DStatus = '" & strStat & "' WHERE TestID = " & arrRecIDs(i)
commUpdate.CommandType = 1
commUpdate.CommandTimeout = 0
commUpdate.Prepared = true
commUpdate.Execute()
Next
'strMessage = i & " Records Updated"
Response.Redirect("AUDoc.asp"
End If
%&gt;
</font id=code></pre id=code>

I have modifed this code to the point in which it runs <i>i.e. It doesn't break on error</i>, but it give me the same error as above:

<pre id=code><font face=courier size=2 id=code>
&lt;%
If Request("Submit" &lt;&gt; "" Then
intRecIDs = Replace(Request("hidRecIDs", "*", "" ' remove all the asterisks, to create a list like this: 2, 5, 8, 9 etc.
arrRecIDs = Split(intRecIDs, ", "
' Create an array, wich will contain just the IDs of the records we need to update
Dim dtBox
dtBox = Replace(Request("txtdue" & arrRecIDs(i)), "'", "''"
IF IsDate(txtdue) THEN
dtBox = Replace(Request("txtdue" & arrRecIDs(i)), "'", "''"
Else
dtBox = Replace(Request("Null" & arrRecIDs(i)), "'", "''"
End IF
For i = 0 to Ubound(arrRecIDs) ' Loop trough the array
dateDue = dtBox
strStat = Replace(Request("txtStat" & arrRecIDs(i)), "'", "''"
set commUpdate = Server.CreateObject("ADODB.Command"
commUpdate.ActiveConnection = MM_DataQCDB_STRING
commUpdate.CommandText = "UPDATE M_Schedule SET DDateCompleted ='" & dateDue & "',
DStatus = '" & strStat & "' WHERE TestID = " & arrRecIDs(i)
commUpdate.CommandType = 1
commUpdate.CommandTimeout = 0
commUpdate.Prepared = true
commUpdate.Execute()
Next
'strMessage = i & " Records Updated"
Response.Redirect("AUDoc.asp"
End If
%&gt;
</font id=code></pre id=code>

I desparetly need help!!!! I have to have this completed by Monday, and this is the only thing that is preventing me from delivering.....

Thank you so much!!!!!

Edited by - carlosrey23 on 26 Apr 2008 22:34:54

Edited by - carlosrey23 on 27 Apr 2008 01:06:40

Reply to this topic