query with "special" character to save


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: query with "special" character to save

  1. #1
    Join Date
    Mar 2008
    Posts
    164

    query with "special" character to save

    hi,
    i need perform the following query to save into db the problem is sometimes the user
    enter some characteres that interfer with the sql command for example

    if the user enter this word: 'hello'
    when i try save this result i error because the final query is this:

    insert into x (v) values (''hello'') and for update this problem ocorr to
    how can i save the value ' to the db replacing the ' charater for other?
    thanks a lot for your help

  2. #2
    Join Date
    Aug 2006
    Posts
    84
    Replace the '(single quote) with ''(2 single quotes) as it is the escape character in Sql Server.

    Code:
    Dim strTemp As String = "'Hello'"
    strTemp.Replace("'", "'''")
    Hope this will help you

  3. #3
    Join Date
    Mar 2008
    Posts
    164
    hi,
    but this dontī resolve the problem imagine that i want save the '
    and load that value i think there is some proper function to handle
    that situation thanks for your help

  4. #4
    Join Date
    Aug 2006
    Posts
    84
    I guess even ' can also be saved... I just tried with VS2008 & SqlServer2005

Similar Threads

  1. Union query
    By peljo in forum Database
    Replies: 4
    Last Post: 12-17-2007, 11:38 AM
  2. Replies: 0
    Last Post: 08-14-2001, 07:22 PM
  3. Save results of query
    By Paul in forum Database
    Replies: 2
    Last Post: 11-28-2000, 07:35 PM
  4. Sending a query to ADO with then character 39 :'
    By Jean-Claude LEPOT in forum authorevents.vaughn
    Replies: 1
    Last Post: 05-31-2000, 12:45 AM
  5. Replies: 1
    Last Post: 05-04-2000, 11:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center