Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Databases
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 7th, 2004, 03:50 PM
Authorized User
 
Join Date: Jan 2004
Location: Half Moon Bay, CA, USA.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default INSERT info into a Access database for display

Bottom Line Question: How do I eliminate this apostrophe problem? Should I run a string search and delete the apostrophe and replace it with Response.Write "´”?

I am trying to create an asp page that will display text that a user submits on a form, and then displays it on another page for customers to read prior to placing an order. I am designing this for a client, since they have limited knowledge of web design, they do not want to get into html coding.

The program takes what they write and puts it in to an Access database, and then another asp page calls it up prior to placing an order.

Everything works, "almost" except for when the client enters text with an apostrophe.

You can find the working site at (This allows the user to enter info, which will be password protected in the future):
http://www.its-sfbay.com/preorder.html

Then it is displayed on (prior to a customer placing an order):
http://www.its-sfbay.com/display.asp

Everything works until an apostrophe is entered anywhere in the field.

Here is the code for this page:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
  Option Explicit
  Dim strConnect
%>

<html>
<head>
<title>Place Order Update</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="text.css" rel="stylesheet" type="text/css">
</head>
<body>
<%
  Const adOpenKeySet = 1
  Const adOpenOptimistic = 2

  Dim objCmd, intNoOfRecords
  set objCmd = Server.CreateObject("ADODB.Command")

  Dim strTitle, strCDate, strCopy, strSQL
  strCDate = Request.Form("currentdate")
  strTitle = Request.Form("title")
  strCopy = Request.Form("copy")

  objCmd.ActiveConnection = strConnect
  objCmd.CommandText = "DELETE FROM PreOrder WHERE ID LIKE '1' "
  objCmd.Execute intNoOfRecords
  'Response.Write "This Update command has affected " & _
                   'intNoOfRecords & " records<br><br>"

  strSQL = "INSERT INTO PreOrder (CDate, Title,Copy) VALUES " & _
             "('" & strCDate & "','" & strTitle & "','" & strCopy &"');"
  objCmd.CommandText = strSQL
  objCmd.Execute intNoOfRecords
  Response.Write "This Record Update command has affected " & _
                   intNoOfRecords & " records<br><br>"


  set objCmd = nothing
%>
</body>
</html>


Reply With Quote
  #2 (permalink)  
Old January 7th, 2004, 04:02 PM
Friend of Wrox
 
Join Date: Jan 2004
Location: , , USA.
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use VbScript Replace function for all the Request.Form variables:
Replace(Request.Form("variable"),"'","''")

Or a use a function like this

Function Fix_String(varString)
    if isnull(varString) then
        Fix_String = ""
    else
        Fix_String = trim(varString)
        Fix_String = Replace(Fix_String,"'","''")
    end if
End Function
Reply With Quote
  #3 (permalink)  
Old January 7th, 2004, 04:25 PM
Authorized User
 
Join Date: Jan 2004
Location: Half Moon Bay, CA, USA.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you shahchi1, the VbScript function works like a charm. I don't think there are any other characters that interrupt this code. I guess I will have to keep testing it!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
INSERT into Access Database from VBA for Excel zuerlein Excel VBA 0 June 3rd, 2007 01:51 AM
Insert row into MS-ACCESS database ITladybug ADO.NET 1 January 28th, 2006 07:57 AM
INSERT string into a Microsoft Access Database gsolis Classic ASP Databases 1 December 31st, 2003 05:31 PM
HELP! How do I insert info. to a database? nvillare VB.NET 2002/2003 Basics 4 December 2nd, 2003 01:44 PM
HELP! How do I insert info. to a database? nvillare VB Databases Basics 0 November 30th, 2003 04:09 PM



All times are GMT -4. The time now is 02:14 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.