tags:

views:

63

answers:

2

i have a problem in inserting the listbox value into mysql database in vb 2008 i.e

if i select a video file i.e D:\videos\video1.mpg and add a msgbox() event before inserting into data base it shows the exact path i.e D:\videos\video1.mpg but when i check my database it shows me as D:videosvideo1.mpg how can i solve that

+1  A: 

Within MySQL string values the backslash is interpreted as an escape character. The following escape sequences have special meaning to MySQL: \0, \', \", \b, \n, \r, \t, \z, \, \%, \_. Any other character preceeded by a backslash is just replaced with that character. So in your example: \v is not a valid escape sequence so it is replaced with just "v" when it is stored. You should alter your path values to contain the "\" sequence to actually store a backslash. Example: D:\\videos\\video1.mpg

tchester
could you please let me know how can i insert double slash auto matically because i am using a listbox to add video file and than i have a button to insert all listbox items into database please let me know how can i add double back slashes...??
Web Worm
Without actually seeing your listbox to database code it's kind of hard to comment. But assuming that you are using some form of a loop to iterate through your listbox contents. As you pull each string value out of the list, use the Replace method before you insert into the database. Example: NewFileName = OldFileName.Replace("\", "\\")
tchester
A: 

try to insert path with two backslash signs, for example "D:\\videos\\video1.mpg" into database.

sanjuro