Connecting Tech Pros Worldwide Forums | Help | Site Map

how to insert '\' character

Member
 
Join Date: Nov 2007
Posts: 125
#1: Nov 28 '08
hello,

i have a field in my table to store a file path. for example it could be 'C:\My Documents\myFolder\myFile'.

when i retrieve the record from mySQL. the value of the file path become 'C:My DocumentsmyFoldermyFile'. without the '\' backslash character.

the question is how to store backslash character in mysql.
Thank you

Member
 
Join Date: Nov 2008
Posts: 52
#2: Nov 28 '08

re: how to insert '\' character


Try double backlashes or use no_backlash_escapes.

Expand|Select|Wrap|Line Numbers
  1. root@test>set sql_mode='NO_BACKSLASH_ESCAPES';
mwasif's Avatar
Moderator
 
Join Date: Jul 2006
Location: Pakistan
Posts: 719
#3: Nov 28 '08

re: how to insert '\' character


How you are saving your data? If you are using some programming language like PHP then you should use addslashes().
Member
 
Join Date: Nov 2007
Posts: 125
#4: Nov 28 '08

re: how to insert '\' character


Hi,

thanks for the reply. well, i use VB .NET as the programming language.
mwasif's Avatar
Moderator
 
Join Date: Jul 2006
Location: Pakistan
Posts: 719
#5: Nov 28 '08

re: how to insert '\' character


The file path should look like this in the query before inserting to MySQL
Expand|Select|Wrap|Line Numbers
  1. C:\\My Documents\\myFolder\\myFile
To achieve this you can use Replace function.
Reply