itortu
asked on
when changing update statement syntax/ receiving errors.
i'm trying to change the update statement:
conn.Execute("UPDATE tblServiceStandards SET Action_Taken = Action_Taken + '" & vbCrLf & dateCompleted & "' + ' " & Action_Taken & "' WHERE ticketnumber = " & ticketnumber & ";")
to this form:
Sub saveVariables
opencon
sql = "SELECT * FROM tblServiceStandards WHERE ticketnumber =" & ticketnumber
set RS = Server.CreateObject("ADODB
RS.Open sql, connectme, 1, 3
if rs.bof = true and rs.eof = true then
response.write ("Record not found!")
else
do until rs.eof = true
if IsDate(dateCompleted) then
Rs.Fields("fldDate") = sfldDate
Rs.Fields("Reported_By").v
Rs.Fields("Severity").valu
Rs.Fields("Duration").valu
Rs.Fields("Status").value = sStatus
Rs.Fields("ServicesAffecte
Rs.Fields("Problem_Descrip
Rs.Fields("Assigned_To").v
Rs.Fields("Action_Taken").
rs.UpdateBatch adAffectAll
exit do
end if
rs.movenext
Loop
end if
closecon
End Sub
and when i submit the page, i get an error that says: "The function expects a string as input" line 213
Rs.Fields("Action_Taken").
i am would like to insert/append into the field Äction_Taken the values dateCompleted, and sAction_Taken which is appended to whatever contents are already on the field.
can i be advise on how do i need to change this line, so all these values are inserted? thanks for all you help. it is very much appreciated. please tell me if increasing the poin value is neccesary.
regards.
itortu.
ASKER
hi! I followed your suggestion and changed it to:
if rs.bof = true and rs.eof = true then
Response.Write("Record not found!")
else
if lcase(cstr(rs.fields("Tick etNumber") .value)) = lcase(cstr(sTicketNumber)) then
Rs.Fields("fldDate") = sfldDate
Rs.Fields("Reported_By").v alue = sReported_By
Rs.Fields("Severity").valu e = sSeverity
Rs.Fields("Duration").valu e = sDuration
Rs.Fields("Status").value = sStatus
Rs.Fields("ServicesAffecte dID").valu e = sServicesAffectedID
Rs.Fields("Problem_Descrip tion").val ue = sProblem_Description
Rs.Fields("Assigned_To").v alue = sAssigned_To
Rs.Fields("Action_Taken"). value = "'" & Rs.Fields("Action_Taken"). value & vbcrlf & dateCompleted & sAction_Taken & " ' "
rs.UpdateBatch adAffectAll
end if
end if
but now all it gets inserted is the single quotes at the beginning of the contents already existent and until the end.
' this text was already on this field '
if rs.bof = true and rs.eof = true then
Response.Write("Record not found!")
else
if lcase(cstr(rs.fields("Tick
Rs.Fields("fldDate") = sfldDate
Rs.Fields("Reported_By").v
Rs.Fields("Severity").valu
Rs.Fields("Duration").valu
Rs.Fields("Status").value = sStatus
Rs.Fields("ServicesAffecte
Rs.Fields("Problem_Descrip
Rs.Fields("Assigned_To").v
Rs.Fields("Action_Taken").
rs.UpdateBatch adAffectAll
end if
end if
but now all it gets inserted is the single quotes at the beginning of the contents already existent and until the end.
' this text was already on this field '
Either dateCompleted and sAction_Taken are empty or you are not seeing the update due to a newline in the text. Take out the vbCrLf and make sure dateCompleted and sAction_Taken has somevalue.
Rs.Fields("Action_Taken"). value = "'" & Rs.Fields("Action_Taken"). value & " - " & dateCompleted & sAction_Taken & " ' "
Rs.Fields("Action_Taken").
ASKER
hi amit_q,
now i can see the other field. i had to add a new field named action_taken_update instead of using action_taken only, otherwise the value were erased let me show you what i am doing ok?
sAction_Taken = Trim(Request.Form("Action_ Taken"))
sAction_Taken = replace(Action_Taken,"'"," ''")
dateCompleted = Server.HTMLEncode(Request. Form("date completed" ))
if lcase(sPageAction) = "" then
LoadVars
ShowEditor
end if
if lcase(sPageAction) = "save" then
SaveVars
ShowOk
end if
Sub LoadVars
opencon
ChooseTable "tblServiceStandards"
if rs.bof = true and rs.eof = true then
Response.Write("Record not found!")
else
do until rs.eof = true
if lcase(cstr(rs.fields("Tick etNumber") .value)) = lcase(cstr(sWhat)) then
sTicketNumber = Rs.Fields("TicketNumber"). value
sfldDate = Rs.Fields("fldDate").value
sReported_By = Rs.Fields("Reported_By").v alue
sSeverity = Rs.Fields("Severity").valu e
sDuration = Rs.Fields("Duration").valu e
sStatus = Rs.Fields("Status").value
sServicesAffectedID = Rs.Fields("ServicesAffecte dID").valu e
sProblem_Description = Rs.Fields("Problem_Descrip tion").val ue
sAssigned_To = Rs.Fields("Assigned_To").v alue
sAction_Taken = Rs.Fields("Action_Taken"). value
exit do
end if
rs.movenext
Loop
end if
closecon
End Sub
Sub SaveVars
opencon
strSQL = "SELECT * FROM tblServiceStandards WHERE ticketnumber=" & sTicketNumber
Set RS = Server.CreateObject("ADODB .Recordset ")
RS.Open strSQL, connectme, 1, 3
if rs.bof = true and rs.eof = true then
Response.Write("Record not found!")
else
if lcase(cstr(rs.fields("Tick etNumber") .value)) = lcase(cstr(sTicketNumber)) then
Rs.Fields("fldDate") = sfldDate
Rs.Fields("Reported_By").v alue = sReported_By
Rs.Fields("Severity").valu e = sSeverity
Rs.Fields("Duration").valu e = sDuration
Rs.Fields("Status").value = sStatus
Rs.Fields("ServicesAffecte dID").valu e = sServicesAffectedID
Rs.Fields("Problem_Descrip tion").val ue = sProblem_Description
Rs.Fields("Assigned_To").v alue = sAssigned_To
Rs.Fields("Action_Taken"). value = "'" & Rs.Fields("Action_Taken"). value & " " & dateCompleted & " " & Request.Form("UpdActionTak en") & " ' "
rs.UpdateBatch adAffectAll
end if
end if
closecon
End Sub
now i can see the other field. i had to add a new field named action_taken_update instead of using action_taken only, otherwise the value were erased let me show you what i am doing ok?
sAction_Taken = Trim(Request.Form("Action_
sAction_Taken = replace(Action_Taken,"'","
dateCompleted = Server.HTMLEncode(Request.
if lcase(sPageAction) = "" then
LoadVars
ShowEditor
end if
if lcase(sPageAction) = "save" then
SaveVars
ShowOk
end if
Sub LoadVars
opencon
ChooseTable "tblServiceStandards"
if rs.bof = true and rs.eof = true then
Response.Write("Record not found!")
else
do until rs.eof = true
if lcase(cstr(rs.fields("Tick
sTicketNumber = Rs.Fields("TicketNumber").
sfldDate = Rs.Fields("fldDate").value
sReported_By = Rs.Fields("Reported_By").v
sSeverity = Rs.Fields("Severity").valu
sDuration = Rs.Fields("Duration").valu
sStatus = Rs.Fields("Status").value
sServicesAffectedID = Rs.Fields("ServicesAffecte
sProblem_Description = Rs.Fields("Problem_Descrip
sAssigned_To = Rs.Fields("Assigned_To").v
sAction_Taken = Rs.Fields("Action_Taken").
exit do
end if
rs.movenext
Loop
end if
closecon
End Sub
Sub SaveVars
opencon
strSQL = "SELECT * FROM tblServiceStandards WHERE ticketnumber=" & sTicketNumber
Set RS = Server.CreateObject("ADODB
RS.Open strSQL, connectme, 1, 3
if rs.bof = true and rs.eof = true then
Response.Write("Record not found!")
else
if lcase(cstr(rs.fields("Tick
Rs.Fields("fldDate") = sfldDate
Rs.Fields("Reported_By").v
Rs.Fields("Severity").valu
Rs.Fields("Duration").valu
Rs.Fields("Status").value = sStatus
Rs.Fields("ServicesAffecte
Rs.Fields("Problem_Descrip
Rs.Fields("Assigned_To").v
Rs.Fields("Action_Taken").
rs.UpdateBatch adAffectAll
end if
end if
closecon
End Sub
ASKER
my fields Reported_by, Severity, Status, ServicesAffectedID, and Assigned_To
are drop down select list boxes.
when the page is load, the sub "LoadVars" is executed and the fields are populated with values from the database. Well, I should say that only the text fields are populated (<TD class="body"><INPUT TYPE="text" NAME="Duration" VALUE="<% Response.WRite(sDuration) %>"></TD>)
since the drop down select lists are hard coded in the page, I don't know how can I place the value from the database, so when the page is load instead of seeing "Selec on please" I see the value from the database, and then the user if neccesary can change it by selecting one of the hard coded values. I don't know if this is possible, at least not the way I am trying to do it, but if I you don't mind, would you please show me how, or explain me how can I achieve this?
Thank you very much.
<TR>
<TD class="head">Reported By</TD>
<TD class="body">
<SELECT NAME="Reported_By">
<OPTION>Select Please</Option>
<OPTION VALUE="DataQC">DataQC</Opt ion>
<OPTION VALUE="Shannon">Shannon</O ption>
<OPTION VALUE="Client Services">Client Services</Option>
<OPTION VALUE="Automated Alert">Automated Alert</Option>
<OPTION VALUE="Weather Central">Weather Central</Option>
<OPTION VALUE="Client">Client</Opt ion>
<OPTION VALUE="Other">Other</Optio n>
</SELECT></TD>
</TR>
<TR>
<TD class="head">Severity</TD>
<TD class="body">
<SELECT NAME="Severity">
<OPTION>Select Please</Option>
<OPTION VALUE="Level 1 - Red" class="uno">Level 1 - Red</Option>
<OPTION VALUE="Level 2 - Orange" class="dos">Level 2 - Orange</Option>
<OPTION VALUE="Level 3 - Yellow" class="tres">Level 3 - Yellow</Option>
</SELECT>
</TD>
</TR>
are drop down select list boxes.
when the page is load, the sub "LoadVars" is executed and the fields are populated with values from the database. Well, I should say that only the text fields are populated (<TD class="body"><INPUT TYPE="text" NAME="Duration" VALUE="<% Response.WRite(sDuration) %>"></TD>)
since the drop down select lists are hard coded in the page, I don't know how can I place the value from the database, so when the page is load instead of seeing "Selec on please" I see the value from the database, and then the user if neccesary can change it by selecting one of the hard coded values. I don't know if this is possible, at least not the way I am trying to do it, but if I you don't mind, would you please show me how, or explain me how can I achieve this?
Thank you very much.
<TR>
<TD class="head">Reported By</TD>
<TD class="body">
<SELECT NAME="Reported_By">
<OPTION>Select Please</Option>
<OPTION VALUE="DataQC">DataQC</Opt
<OPTION VALUE="Shannon">Shannon</O
<OPTION VALUE="Client Services">Client Services</Option>
<OPTION VALUE="Automated Alert">Automated Alert</Option>
<OPTION VALUE="Weather Central">Weather Central</Option>
<OPTION VALUE="Client">Client</Opt
<OPTION VALUE="Other">Other</Optio
</SELECT></TD>
</TR>
<TR>
<TD class="head">Severity</TD>
<TD class="body">
<SELECT NAME="Severity">
<OPTION>Select Please</Option>
<OPTION VALUE="Level 1 - Red" class="uno">Level 1 - Red</Option>
<OPTION VALUE="Level 2 - Orange" class="dos">Level 2 - Orange</Option>
<OPTION VALUE="Level 3 - Yellow" class="tres">Level 3 - Yellow</Option>
</SELECT>
</TD>
</TR>
Looks ok but note that the loop in Sub LoadVars is overwritting the variables. So in the end you always get variables populated with last row fetched from the database. That might be ok if you are getting only single row from the database but even in that case you should remove the loop and just have f rs.bof = true and rs.eof = true then so that the reader of the code know what is happening.
ASKER
i got rid of the loop, but now the page does not have any of its fields populated?
this is how it looks:
Sub LoadVars
opencon
ChooseTable "tblServiceStandards"
if rs.bof = true and rs.eof = true then
if lcase(cstr(rs.fields("Tick etNumber") .value)) = lcase(cstr(sWhat)) then
sTicketNumber = Rs.Fields("TicketNumber"). value
sfldDate = Rs.Fields("fldDate").value
sReported_By = Rs.Fields("Reported_By").v alue
sSeverity = Rs.Fields("Severity").valu e
sDuration = Rs.Fields("Duration").valu e
sStatus = Rs.Fields("Status").value
sServicesAffectedID = Rs.Fields("ServicesAffecte dID").valu e
sProblem_Description = Rs.Fields("Problem_Descrip tion").val ue
sAssigned_To = Rs.Fields("Assigned_To").v alue
sAction_Taken = Rs.Fields("Action_Taken"). value
end if
end if
closecon
End Sub
this is how it looks:
Sub LoadVars
opencon
ChooseTable "tblServiceStandards"
if rs.bof = true and rs.eof = true then
if lcase(cstr(rs.fields("Tick
sTicketNumber = Rs.Fields("TicketNumber").
sfldDate = Rs.Fields("fldDate").value
sReported_By = Rs.Fields("Reported_By").v
sSeverity = Rs.Fields("Severity").valu
sDuration = Rs.Fields("Duration").valu
sStatus = Rs.Fields("Status").value
sServicesAffectedID = Rs.Fields("ServicesAffecte
sProblem_Description = Rs.Fields("Problem_Descrip
sAssigned_To = Rs.Fields("Assigned_To").v
sAction_Taken = Rs.Fields("Action_Taken").
end if
end if
closecon
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>i got rid of the loop, but now the page does not have any of its fields populated?
What is your select statement. You might have to use a where clause in it.
What is your select statement. You might have to use a where clause in it.
ASKER
for this part:
<OPTION VALUE="Level 1 - Red" class="uno" <%if WhateverVariable = "Level1" then response.write "selected"%>>Level 1 - Red</Option>
whatever variable is the name of the record set variable?
thank you.
<OPTION VALUE="Level 1 - Red" class="uno" <%if WhateverVariable = "Level1" then response.write "selected"%>>Level 1 - Red</Option>
whatever variable is the name of the record set variable?
thank you.
ASKER
ok i got it it is the name of the form variable "sSeveirty" : )
ASKER
i still don't know how to get rid of the single quotes that are inserted with the update of the action taken field?'
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Rs.Fields("Action_Taken").