473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Pathname to be put into table has single quote as part of name

Part of a table I have requires the pathname to a photostat of the check to placed into a field.

Example, c:/foldera/folderb/The Hitchhiker's Guide to the Galaxy.png

Well the ' in the name gives me fits. Error 42703.. I tried putting the string in quotes, "\"", but still a no-go.

Any ideas?

Thanks.
Sep 4 '15 #1
2 1469
Ok, figured it out. Apostrophe is the answer.
That is double apostrophe.This will do it.

Expand|Select|Wrap|Line Numbers
  1. string xfile_path = "c:/foldera/folderb/The Hitchhiker's Guide to the Galaxy.png"
  2. string x = "\'";                   // what we want replaced
  3. if (xfile_path.ToString().IndexOfAny(new char[] { '\'' }) > -1)    
  4.     {
  5.       //* so we fix it
  6.       string tests = xfile_path.ToString();
  7.       tests = tests.Replace(x.ToString(), "\'\'");  //  <--- the answer. two single quotes (apostrophe)!
  8.       xfile_path = tests.ToString();             // put the toothpaste back into the tube
  9.       }
  10.  
  11. //now the xfile_path has "c:/foldera/folderb/The Hitchhiker''s Guide to the Galaxy.png
  12.  
  13. //And SQL will take that as being "c:/foldera/folderb/The Hitchhiker's Guide to the Galaxy.png"!
Sep 4 '15 #2
You should never use special characters as a file path. That includes spaces ( although they are allowed it's best to stay away from all special characters and stick with numbers and letters.
Sep 7 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: ChadDiesel | last post by:
Hello everyone. I need some advice on table structure for a new project I've been given. One of our customers sends us an Excel spreadsheet each week containing their order. Currently, someone...
3
by: micmic | last post by:
Deear all experts, In the MySQL, we can use escape character '\' to save the STRING WITH single quote into database (eg. we would like to insert into table "tbl_ABC"with the string ab'c, we...
4
by: Jack | last post by:
Hi, I have a asp page where part of the code is as follows. This builds up the sql statement partially. sql01 = "UPDATE EquipmentTbl SET " sql01 = sql01 & "SerialNumber = '" &...
0
by: Alex | last post by:
Hi, I made a deployment package that needs to install its files to a folder which name contains a single quote (it's in french). I changed the Application folder's default location to point to...
3
by: Eric Layman | last post by:
Hi, I've saved data into the db by doing a replace() on single quote. Right now on data display on a datagrid, it shows double single quote. How do I make changes during run time of datagrid...
4
by: =?Utf-8?B?QUMgW01WUCBNT1NTXQ==?= | last post by:
Trying to use reflection to obtain the 4-part name of a strong named assembly (assembly, version, culture, publickeytoken) and immediately release the reference. I’m currently doing the...
0
by: dhascuba | last post by:
The @name field can contain a single quote in it such as: Mike O'Grady. Since this is creating and SQL statement on the server side, it will not process the name if it has a single quote in it. Id'...
1
by: =?Utf-8?B?U2FpbXZw?= | last post by:
Hello. I have a problem about single quote search in C#. I have 1 table: ID NAME COMPANY 1 Sayre One 1' Sayre Two
4
by: pavanponnapalli | last post by:
hi, I need to send some values to a subroutine where i use insert query. suppose say my scalar is as follows: my ($name,$number,$address) etc and i get the values into those...
10
nomad
by: nomad | last post by:
I have a testimonial page where the user can write a testimonial for me. I get this error message if the user use a single quote mark. example: Demonstrated professionalism and creativity as the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.