i’m using MySQL With .Net(C#), and i want to store drive path in DB
example: “D:\” OR “\NetworkDrive”, and i use
MySqlCommand objCommand = new MySqlCommand(strSql, Connection);
objCommand.CommandType = CommandType.StoredProcedure;
objCommand.Parameters.Add(new MySqlParameter("paramName","D:\\");
objCommand.ExecuteNonQuery();
it return error Like this “Unhandled type encountered”
I try to escape the path like this
objCommand.Parameters.Add(new MySqlParameter("paramName","D:\\\\");
objCommand.Parameters.Add(new MySqlParameter("paramName",@"D:\\");
objCommand.Parameters.Add(new MySqlParameter("paramName","D:\\");
also it’s not working.
I had a similar problem using MS-SQL, where I wanted to put a single quote into a query. Use a MYSQL escape character, the list of which are here:
http://dev.mysql.com/doc/refman/5.0/en/string-syntax.html
Basically if you know for a fact one of those problem characters are going to be in your query, escape them out with .replace before you build your query.