How to replace apostrophe in ASP record set

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chandhseke
    New Member
    • Jun 2009
    • 92

    #1

    How to replace apostrophe in ASP record set

    Hi Folks,

    I have designed a functionality to EDIT or DELETE dropdown values with an ADMIN privilge. MY code will pull the approver names from a database and will give an option to edit or delete. I am able to do it, but the real problem is when the approver names or email contains an apostrophe I will not be able to action the edit or delete button. Please help since this is a priority issue for me.
    I know the technolgy that we are using is old but i need a way so that i can pass a name or email with apostrophe.

    Can i use Replace(Trim("X XX")),"'","''") ) with record set (Rs1). Please advise.

    Code:
    <html>
    <head>
    <meta name="GENERATOR" Content="Microsoft FrontPage 6.0">
    <meta http-equiv="PRAGMA" content="no-store">
    <title>List of OGC Contact</title>
    </head>
    <body>
    <table border="0" width="100%" cellspacing="4" cellpadding="4">
    <tr>
    <td>
    <%SQL = "Select * from OGC_Contact where Deleted = 'No' order by OGC_Contact ASC"
    Set Rs1 = Server.CreateObject("ADODB.RecordSet")
    Rs1.Open SQL, Oconn
    %>
     
    <table border="1" width="100%" cellspacing="3" cellpadding="3">
    				<tr>			
    					<td class=textbold1863ad width="23%"><div align=center>Theater</div></td>
    					<td class=textbold1863ad width="23%"><div align=center>OGC Contact Name</div></td>
    					<td class=textbold1863ad width="23%"><div align=center>OGC Contact Email</div></td>
    				</tr> 
    <% Do Until Rs1.EOF %>
    
    <tr>
    				    <td><div align="center"><font face="Arial" size="2"><%=Rs1("Theatre")%></font></div></td>
    				    <td><div align="center"><font face="Arial" size="2"><%=Rs1("OGC_Contact")%></font></div></td>
    				    <td><div align="center"><font face="Arial" size="2"><%=Rs1("OGC_Email")%></font></div></td>
    				    <td align=center>
    
    				    <input type=button  name="Edit" id="Edit" value="Edit" onclick="window.location='SDS_OGCEdit.asp?Theatre=<%=Rs1("Theatre")%>&OGC_Contact=<%=Rs1("OGC_Contact")%>&OGC_Email=<%=Rs1("OGC_Email")%>&Mode=Edit'">&nbsp;
    					<input type=button name="Delete" id="Delete" value="Delete" onclick="window.location='SDS_OGCEdit.asp?Theatre=<%=Rs1("Theatre")%>&OGC_Contact=<%=Rs1("OGC_Contact")%>&OGC_Email=<%=Rs1("OGC_Email")%>&Mode=Delete'"></td>
    </tr>
    <%Rs1.movenext 
    loop
    %>					
    </td>
    <tr>
          <td colspan=4 align=center><input type="button" value="Back to Main Menu" name="Back" onclick="window.location='SDSAdminEdit.asp';"></td>
    </tr></tr>
    </table>
    <%Rs1.Close
    Set Rs1 = nothing
    oConn.Close
    Set oConn=nothing
    %>
    </body></html>
    <%End If %>
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    Originally posted by chandhseke
    Can i use Replace(Trim("X XX")),"'","''") ) with record set (Rs1). Please advise.
    yes and no, depending when you try to do the replace. It might also be useful to convert the apostrophe to the HTML character code at the point where the names are saved into the db.

    Jared

    Comment

    • senweb
      New Member
      • Jun 2010
      • 2

      #3
      Originally posted by chandhseke
      Hi Folks,

      I have designed a functionality to EDIT or DELETE dropdown values with an ADMIN privilge. MY code will pull the approver names from a database and will give an option to edit or delete. I am able to do it, but the real problem is when the approver names or email contains an apostrophe I will not be able to action the edit or delete button. Please help since this is a priority issue for me.
      I know the technolgy that we are using is old but i need a way so that i can pass a name or email with apostrophe.

      Can i use Replace(Trim("X XX")),"'","''") ) with record set (Rs1). Please advise.

      Code:
      <html>
      <head>
      <meta name="GENERATOR" Content="Microsoft FrontPage 6.0">
      <meta http-equiv="PRAGMA" content="no-store">
      <title>List of OGC Contact</title>
      </head>
      <body>
      <table border="0" width="100%" cellspacing="4" cellpadding="4">
      <tr>
      <td>
      <%SQL = "Select * from OGC_Contact where Deleted = 'No' order by OGC_Contact ASC"
      Set Rs1 = Server.CreateObject("ADODB.RecordSet")
      Rs1.Open SQL, Oconn
      %>
       
      <table border="1" width="100%" cellspacing="3" cellpadding="3">
      				<tr>			
      					<td class=textbold1863ad width="23%"><div align=center>Theater</div></td>
      					<td class=textbold1863ad width="23%"><div align=center>OGC Contact Name</div></td>
      					<td class=textbold1863ad width="23%"><div align=center>OGC Contact Email</div></td>
      				</tr> 
      <% Do Until Rs1.EOF %>
      
      <tr>
      				    <td><div align="center"><font face="Arial" size="2"><%=Rs1("Theatre")%></font></div></td>
      				    <td><div align="center"><font face="Arial" size="2"><%=Rs1("OGC_Contact")%></font></div></td>
      				    <td><div align="center"><font face="Arial" size="2"><%=Rs1("OGC_Email")%></font></div></td>
      				    <td align=center>
      
      				    <input type=button  name="Edit" id="Edit" value="Edit" onclick="window.location='SDS_OGCEdit.asp?Theatre=<%=Rs1("Theatre")%>&OGC_Contact=<%=Rs1("OGC_Contact")%>&OGC_Email=<%=Rs1("OGC_Email")%>&Mode=Edit'">&nbsp;
      					<input type=button name="Delete" id="Delete" value="Delete" onclick="window.location='SDS_OGCEdit.asp?Theatre=<%=Rs1("Theatre")%>&OGC_Contact=<%=Rs1("OGC_Contact")%>&OGC_Email=<%=Rs1("OGC_Email")%>&Mode=Delete'"></td>
      </tr>
      <%Rs1.movenext 
      loop
      %>					
      </td>
      <tr>
            <td colspan=4 align=center><input type="button" value="Back to Main Menu" name="Back" onclick="window.location='SDSAdminEdit.asp';"></td>
      </tr></tr>
      </table>
      <%Rs1.Close
      Set Rs1 = nothing
      oConn.Close
      Set oConn=nothing
      %>
      </body></html>
      <%End If %>
      replace(rs1("st ate"),"'","''" )

      Comment

      Working...