Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 26th, 2005, 09:49 AM
Authorized User
 
Join Date: Jun 2005
Posts: 42
Thanks: 0
Thanked 1 Time in 1 Post
Default SQL Apostrophy

Hi, I am trying to insert a text value into an SQL table. The name of the field is comments. And its contents can be a word, a sentence or a paragraph.

Example:

The house’s door was broken. Willie’s dog was who did it.

As you can see this sample has two apostrophizes. When I try to insert this text into SQL. SQL return with this value.

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 's'.
I am calling this procedure from an ASP Page.
Can someone help with this issue? I know that there is a solution.



arnniema
__________________
arnniema
 
Old September 26th, 2005, 10:17 AM
Authorized User
 
Join Date: Jun 2005
Posts: 42
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi, is me again. I found the solution. This is how to do it using vbscript:
1. first remove any leading spaces.
StatusComment = trim(txtStatusComment)
2. find the length of the variable in question
L=len(trim(StatusComment))
3. declare a dommy variable
Dim TXT1
4. write a loop
for z = 1 to L
5. write a decision testing to look for an apostrophy
6. while running the loop test for the presents of the apostrophy
7. if it is found add the apostrophy code as it is below
8. else add the characters that aren’t apostrophy until the loop end.
   if mid(StatusComment, z, 1) = "'" then
        TXT1 = TXT1 & "'" & chr(39) & ""
   else
        TXT1 = TXT1 & mid(StatusComment, z, 1)
   end if
next


The entire sample code
***********************
StatusComment = trim(txtStatusComment)
L=len(trim(StatusComment))
Dim TXT1
for z = 1 to L
    if mid(StatusComment, z, 1) = "'" then
        TXT1 = TXT1 & "'" & chr(39) & ""
    else
    TXT1 = TXT1 & mid(StatusComment, z, 1)
    end if
next


arnniema
 
Old September 27th, 2005, 04:03 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii arnniema!!

user replace method
i.e.
vLastName = Replace(vLastName, "'", "''")

now use this vLastName in ur sql statement.
plz check the link
http://searchvb.techtarget.com/tip/1...my=%2Fpr%2F4f0

Hope this will help you




Cheers :)

vinod





Similar Threads
Thread Thread Starter Forum Replies Last Post
How Run .sql Script file in MS SQL Server 2000? aarkaycee SQL Server 2000 5 October 12th, 2009 05:43 AM
creating ssis packagte for sql server to sql serer Laxmikant_it ASP.NET 3.5 Professionals 0 November 26th, 2008 12:23 AM
Converting from MS SQL 2005 to Sql Epress edition saif44 SQL Language 0 February 16th, 2007 04:17 PM
Failed to copy objects from SQL server to SQL Serv monfu SQL Server 2000 4 December 4th, 2005 05:54 PM
Move SQL DB from one sql to another sql server Israr SQL Server 2000 3 January 24th, 2005 02:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.