473,609 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

6 New Member
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 1480
DeafSmith
6 New Member
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
TamarSolutions
2 New Member
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
3162
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 formats the spreadsheet, prints it out, and manually picks out the products we need to ship. I want to import this into an Access table. Basically, the sheet with some data examples looks something like this: ...
3
11237
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 can use the following SQL query to insert into database : Insert into tbl_ABC VALUES ('ab\'c'); ). Also there is some functions in mySQL api so that we can save the single quote into MySql database using C programme. But it seems that i cannot do...
4
5598
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 = '" & request.form(strSerialNum) & "', " sql01 = sql01 & "Description = '" & request.form(strDesc) & "', " sql01 = sql01 & "Location = '" & request.form(strLoc) & "', "
0
920
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 my folder but when I build the solution, I get an error telling me that it is unable to create the folder named 'Application folder'. If I remove the quote from the folder name, the project is successfully built. Strangely, I tried to tweak my msi...
3
2732
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 so that the double single quote will be replaced as single quote? Pls advise.
4
1301
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 following: Assembly projectAssembly = Assembly.ReflectionOnlyLoadFrom(projectAssemblyFullPath); fourPartName = projectAssembly.FullName; projectAssembly = null; The problem is that the reference to the assembly is still being held after
0
2144
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' like to replace that single quote with 2 single quotes without destroying th rest of th data in the field. Currently I replace a single quote with a "^" and then do a replace of that on the server side, see last <zz>. That statement is ecexuted on...
1
2473
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
3955
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 scalars dynamically by some other process. When i send these values to the subroutine containing an insert query, there for the columns containing varchar i need to have ' some value' for int no quotes are requried. For example if we take $name,...
10
2989
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 company's web and marketing materials designer. Will produce this error; You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 's web and marketing materials...
0
8554
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8229
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5523
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4030
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4094
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2538
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1683
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1399
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.