如果文件名在C#中有额外的点获取异常,则喷射连接字符串模板 [英] If file name have extra dot getting exception in C#, jet connection string template

查看:79
本文介绍了如果文件名在C#中有额外的点获取异常,则喷射连接字符串模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果文件名有下面的附加点字符:



sample.data.csv下一个选择语句:



SELECT * FROM [sample.data.csv]
带有连接字符串的




Provider = Microsoft.Jet.OLEDB。 4.0;数据源=C:\ Data \;扩展属性=text; HDR = Yes; Format = Delimited;;

获得以下异常:



Microsoft Jet数据库引擎可以找不到对象'样本'



我尝试过:



If file name has additional dot character like below:

sample.data.csv next select statement:

SELECT * FROM [sample.data.csv]
with connection string:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source="C:\Data\"; Extended Properties="text;HDR=Yes;Format=Delimited;";
Getting below exception:

The Microsoft Jet database engine could not find the object 'sample'

What I have tried:

If file name has additional dot character like below:

sample.data.csv next select statement:

SELECT * FROM [sample.data.csv]
with connection string:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source="C:\Data\"; Extended Properties="text;HDR=Yes;Format=Delimited;";
Getting below exception:

The Microsoft Jet database engine could not find the object 'sample'

推荐答案

请参阅文档:表名限制| Microsoft Docs [ ^ ]

See the documentation: Table Name Limitations | Microsoft Docs[^]
Quote:

表名可以包含任何有效字符(例如空格)。如果表名包含除字母,数字和下划线之外的任何字符,则必须通过将其括在后引号(`)中来对名称进行分隔。

Table names can contain any valid characters (for example, spaces). If table names contain any characters except letters, numbers, and underscores, the name must be delimited by enclosing it in back quotes (`).



请尝试:


So try:

SELECT * FROM `sample.data.csv`


参见使用OleDb导入文本文件(选项卡,CSV,自定义) [ ^ ]。


这篇关于如果文件名在C#中有额外的点获取异常,则喷射连接字符串模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆