使用自定义文件扩展名查询平面文件时出错(Error when SQL

编程入门 行业动态 更新时间:2024-10-26 19:38:41
使用自定义文件扩展名查询平面文件时出错(Error when SQL-querying flatfiles with custom file-extension)

我正在寻找一种直接通过SQL查询自定义文件扩展名的flatfiles的方法。

通常使用类似的东西

SELECT * FROM [Text;DATABASE=C:\Flatfiles].[S7121070_ppis#csv]

它与.txt,.csv和.tab一起使用效果非常好。

但是,在我目前的项目中,我使用带有.ftp7扩展名的固定宽度平面文件。 使用VBA查询这些文件时,遇到Err#-2147217911,声明对象或数据库已被锁定。

奇怪的是,只有在我查询不是 .txt,.csv或.tab的任何内容时才会发生这种情况。 意味着无法查询myfile.ftp7 , myfile.ftp , myfile.abc或myfile 。

不能这样做或者我只是遗漏了什么? 谢谢你的帮助! 干杯,马丁

附加信息:

我使用Excel或Access与VBA 将.ftp7重命名为.csv,.txt,.tab解决了这个问题,但是由于只读访问权限而禁止使用 我可以使用schema.ini -files来描述数据结构,所以我希望实际的文件扩展名或多或少是多余的,用于解释文件内容

I'm looking for a way to query flatfiles with custom file-extensions directly via SQL.

Normally use something like

SELECT * FROM [Text;DATABASE=C:\Flatfiles].[S7121070_ppis#csv]

which works terrific with .txt, .csv and .tab.

However, in my current project I work with fixed-width flatfiles with an .ftp7-extension. When querying those files in with VBA, I encounter Err# -2147217911, stating that the object or database is locked.

Oddly, this occurs only whenever I querying anything that's not a .txt, .csv or .tab. Meaning myfile.ftp7, myfile.ftp, myfile.abc or myfile can't be queried.

Can't this be done or am I simply missing something? Thanks for your help! Cheers, Martin

Additional Info:

I use either Excel or Access with VBA Renaming .ftp7 to .csv, .txt, .tab solves the problem, but is a no-no due to read-only access I can use a schema.ini-files to describe the data-structure, so i would have expected that the actual file-extension is more or less redundant for interpreting the files contents

最满意答案

作为Fionnuala postet: 编辑注册表似乎解决了这个问题。

As postet by Fionnuala: Editing the registry seems to solve the problem.

更多推荐

本文发布于:2023-08-06 19:22:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1455337.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   平面   文件扩展名   文件   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!