meth
02-26-2003, 10:38 AM
ASP/VB update command to access database.
This update command manipulates the correct access cell, however instead of replacing the value, it concatenates it to the character-limit of the cell.
e.g. "original", becomes "original, substitute"
I have a few ideas about what's going on, but anything I try to correct the command just throws an error. Please, any advice on an edit will be welcome.
code:
-------------------------------------------------------------------------
<%
if(Request("someValue") <> "") then cmdDoIt__varsomeValue = Request("someValue")
if(Request("someID") <> "") then cmdDoIt__varsomeID = Request("someID")
%>
----truncated------------
<%
IF Request("Submitted") <> "" THEN
IF (Request("someID") <> "") THEN
set cmdDoIt = Server.CreateObject("ADODB.Command")
cmdDoIt.ActiveConnection = MM_connGGG2_STRING
cmdDoIt.CommandText = "UPDATE someTable SET someValue= '" + Replace(cmdDoIt__varsomeValuel, "'", "''") + "' WHERE someID IN (" + Replace(cmdDoIt__varsomeID, "'", "''") + ")"
cmdDoIt.CommandType = 1
cmdDoIt.CommandTimeout = 0
cmdDoIt.Prepared = true
cmdDoIt.Execute()
END IF
Response.Redirect("samePage.asp")
END IF
%>
----------------------------------------------------------------------------
The conditionals ensure the multiple list of records is updated for only the records where the checkbox (someValue) is selected.
I'd simple like to know how to edit this command to do a true replace, and if poss - why this code isn't doing the job properly...
This update command manipulates the correct access cell, however instead of replacing the value, it concatenates it to the character-limit of the cell.
e.g. "original", becomes "original, substitute"
I have a few ideas about what's going on, but anything I try to correct the command just throws an error. Please, any advice on an edit will be welcome.
code:
-------------------------------------------------------------------------
<%
if(Request("someValue") <> "") then cmdDoIt__varsomeValue = Request("someValue")
if(Request("someID") <> "") then cmdDoIt__varsomeID = Request("someID")
%>
----truncated------------
<%
IF Request("Submitted") <> "" THEN
IF (Request("someID") <> "") THEN
set cmdDoIt = Server.CreateObject("ADODB.Command")
cmdDoIt.ActiveConnection = MM_connGGG2_STRING
cmdDoIt.CommandText = "UPDATE someTable SET someValue= '" + Replace(cmdDoIt__varsomeValuel, "'", "''") + "' WHERE someID IN (" + Replace(cmdDoIt__varsomeID, "'", "''") + ")"
cmdDoIt.CommandType = 1
cmdDoIt.CommandTimeout = 0
cmdDoIt.Prepared = true
cmdDoIt.Execute()
END IF
Response.Redirect("samePage.asp")
END IF
%>
----------------------------------------------------------------------------
The conditionals ensure the multiple list of records is updated for only the records where the checkbox (someValue) is selected.
I'd simple like to know how to edit this command to do a true replace, and if poss - why this code isn't doing the job properly...