Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 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
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 26th, 2005, 09:49 AM
Authorized User
 
Join Date: Jun 2005
Location: Miami, fl, USA.
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
  #2 (permalink)  
Old September 26th, 2005, 10:17 AM
Authorized User
 
Join Date: Jun 2005
Location: Miami, fl, USA.
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
  #3 (permalink)  
Old September 27th, 2005, 04:03 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
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
 


Thread Tools
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
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 25th, 2008 11:23 PM
Converting from MS SQL 2005 to Sql Epress edition saif44 SQL Language 0 February 16th, 2007 03:17 PM
Failed to copy objects from SQL server to SQL Serv monfu SQL Server 2000 4 December 4th, 2005 04:54 PM
Move SQL DB from one sql to another sql server Israr SQL Server 2000 3 January 24th, 2005 01:13 PM



All times are GMT -4. The time now is 01:58 PM.


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