Question : .NET MySQL question

if (folderpathsfound.Tables[0].Rows.Count == 0)
                {
                    //Insert new folder path
                    tempsql = "insert into FolderPaths (FolderPath) values ('" + folderlocation + "')";
                    DataHelper.RunSQLStatement(tempsql);

                    SetDefaultFolderLocation(folderlocation);
                }


folderlocation = "C:\\Users\\Mike\\Desktop"

But after the insert, it looks like this in the database:

"C:UsersMikeDesktop"


The backslashes are getting removed.


How can I keep the slashes from getting stripped-out?


Thanks!


Tom

Answer : .NET MySQL question

try one of these changes:
folderlocation = @"C:\Users\Mike\Desktop";
OR
folderlocation = @"C:[\]Users[\]Mike[\]Desktop";


Putting @ in front of a string tells the program not to use escape characters. I think MySQL may use backslashes to escape characters as well, so using brackets will squash that.
Random Solutions  
 
programming4us programming4us