ciao...allora io ho la seguente funzione di modifica dei campi di una tabella....
come modifico con replace per far si che l'utente quando aggiorna il campo possa scrivere anche l'apostrofo altrimenti dà errore???codice:Sub EditItem() Response.write ("<h2>Modifica record nella tabella " & strTable & "</h2>") which=request("which") if isNumeric(which) then MySQL="SELECT * FROM " & strTable & " Where " & strKey & " = " & which else MySQL="SELECT * FROM " & strTable & " Where " & strKey & " = '" & which & "'" end if Set MyRs=MyConn.Execute(MySQL) Response.write ("<FORM ACTION=""" & strFile & "?mode=EditItemAction"" METHOD=POST>") Response.write ("<input name=""ID"" type=""hidden"" value=""" & MyRs(strKey) & """>") Response.write ("<table>") numerocampi=MyRs.fields.count -1 for i=0 to numerocampi if Not MyRs(i).name = "ID" then ThisRecord = MyRs(i) ThisRecordName = MyRs(i).name If IsNull(ThisRecord) or ThisRecord = "" Then ThisRecord = "" end if Response.write ("<tr>") Response.write ("<td height =""auto"" align=""right"">" & ThisRecordName & ": </td>") Response.write ("<td> <input name=""" & ThisRecordName & """ type=""text"" value=""" & MyRs(i) & """></td>") Response.write ("</tr>") end if next Response.write ("<tr>") Response.write ("<td align=""right""><INPUT NAME=""Submit"" TYPE=Submit Value=""Update""></td>") Response.write ("<td><INPUT NAME=""Reset"" TYPE=Reset Value=""Reset""></td>") Response.write ("</tr>") Response.write ("</table>") Response.write ("</FORM>") Response.write ("Torna alla lista dei record") MyRs.close Set MyRs= Nothing End Sub Sub EditItemAction() which = Request(strKey) which=replace which("'","''") if isNumeric(which) then MySQL="SELECT * FROM " & strTable & " Where " & strKey & " = " & which else MySQL="SELECT * FROM " & strTable & " Where " & strKey & " = '" & which & "'" end if 'MySQL="Select * from " & strTable Set MyRs=MyConn.Execute(MySQL) numerocampi=MyRs.fields.count -1 for i=0 to numerocampi if Not MyRs(i).name = "ID" then str = MyRs(i).name strNames = Request(str) if not i = numerocampi then str1 = str1 & "[" & str & "] = '" & strNames & "', " else str1 = str1 & "[" & str & "] = '" & strNames & "'" end if end if next if isNumeric(which) then MySQL1="UPDATE " & strTable & " SET " & str1 & " Where " & strKey & " = " & which else MySQL1="UPDATE " & strTable & " SET " & str1 & " Where " & strKey & " = '" & which & "'" end if 'MySQL1="UPDATE " & strTable & " SET " & str1 & " Where ID=" & which Set MyRs1=MyConn.Execute(MySQL1) MyConn.Close set MyConn=nothing Response.Redirect strFile End Sub
grazie 1000

Rispondi quotando