无法访问文件路径,因为文件夹名称包含空格和特殊字符
我正在访问硬编码路径中的 DBF 数据库文件,但文件夹名称包含 ex--BSTR-VSD、BSTR~VSD 的特殊字符,我无法重命名它。
所以当我建立 odbc 连接时说 odb 然后将查询放入 odb.commandText = select * from PATH(包含具有特殊字符的文件夹名称的硬编码路径)然后给出错误
示例:
System.Data.Odbc.OdbcCommand oCmd = oConn.CreateCommand(); oCmd.CommandText = "SELECT * FROM "+ 路径名 + " 其中 DATE_Y >=110 且 DATE_M >= " + From_Month + " 且 DATE_D>=" + From_Day + " 且 DATE_Y <=110 且 DATE_M <= " + To_Month + " 和 DATE_D<=" + To_Day + " ";
dt_Dbf.Load(oCmd.ExecuteReader());
和例外:: 错误 [42000] [Microsoft][ODBC dBase 驱动程序] FROM 子句中存在语法错误。
I am accessing DBF database file which is in hardcoded path, but the folders name contains special character for ex--BSTR-VSD,BSTR~VSD and I can't rename that.
so when i am making odbc connection say odb and then putting the query into
odb.commandText = select * from PATH(hard coded path which contain folder names having special character) then it gives the error
Example:
System.Data.Odbc.OdbcCommand oCmd = oConn.CreateCommand();
oCmd.CommandText = "SELECT * FROM "+ Pathname + " where DATE_Y >=110 and DATE_M >= " + From_Month + " and DATE_D>=" + From_Day + " and DATE_Y <=110 and DATE_M <= " + To_Month + " and DATE_D<=" + To_Day + " ";
dt_Dbf.Load(oCmd.ExecuteReader());
and exception::
ERROR [42000] [Microsoft][ODBC dBase Driver] Syntax error in FROM clause.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
用括号括起来
您还可以使用诸如
开始日期和结束日期之间
Surround with Brackets
You can also clean this up using things like
betweem StartDate and EndDate
为什么不使用参数化查询?您可以使用OdbcParameter 类。
Why not using Parametrized Query? You can use OdbcParameter class.