[英]Saving the FolderBrowserDialog Selected Path to database using MySQL and C#
Example: Here is my selected path
from browserdialog
示例:这是我从browserdialog
selected path
C:\Users\PHWS13\Desktop
After saving it to database, the path goes like this 将其保存到数据库后,路径如下
C:UsersPHWS13Desktop
My Datatype for the path field is VARCHAR(100)
我的路径字段的数据类型是VARCHAR(100)
Here is my SQL query 这是我的SQL查询
CREATE DEFINER=`xxxxxxxx`@`%` PROCEDURE `AddFolder`(folder_loc VARCHAR(100))
BEGIN
INSERT INTO `tbl_folder`(`folder_location`) VALUES(folder_loc);
How can I fix this? 我怎样才能解决这个问题?
C# code: C#代码:
public void AddFolder(string f)
{
cn.Open();
cmd = new MySqlCommand("call AddFolder('" + f + "')", cn);
cmd.ExecuteNonQuery();
cn.Close();
}
You need to escape \\
by using \\\\
instead. 您需要使用\\\\
来转义\\
。
Try this at the beginning of your AddFolder method: 在您的AddFolder方法的开头尝试以下操作:
f=f.Replace("\\","\\\\");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.