打开具有 2 个“扩展名”的文件时出现 Jet 错误 3011

发布于 2024-08-04 11:27:31 字数 546 浏览 10 评论 0原文

当我尝试使用 Jet 打开具有 2 个“扩展名”(“filename.tst.csv”)的文件时,我遇到了 Jet 抛出错误 3011 的问题。

运行时错误“3011”

Microsoft Jet 数据库引擎找不到对象“filename.tst.csv”。确保该对象存在,并且其名称和路径名称拼写正确。

代码如下所示:

Dim db as Database, rs as Recordset
Set db = OpenDatabase("SELECT TOP 1 * FROM [" & fileName & "];")
Set rs = db.OpenRecordset("SELECT TOP 1 * FROM [" & fileName & "];")

我已经追踪到问题是第二个扩展名(或明显的扩展名)“.tst”,但我不确定为什么会发生错误,而且我无法找到答案通过谷歌或通过这里 - 但我认为有人可能对这些限制有一些见解。

这是在 VB6 中使用 DAO 3.6。

I'm having a problem with Jet throwing error 3011 when I try to use it to open a file with 2 "extensions" ("filename.tst.csv").

Run-time error '3011'

The Microsoft Jet database engine could not find the object 'filename.tst.csv'. Make sure the object exists and that you spell its name and the path name correctly.

Where the code looks like this:

Dim db as Database, rs as Recordset
Set db = OpenDatabase("SELECT TOP 1 * FROM [" & fileName & "];")
Set rs = db.OpenRecordset("SELECT TOP 1 * FROM [" & fileName & "];")

I've tracked down the problem to be the second extension (or apparent extension) ".tst" but I'm not sure why the error is occurring and I haven't been able to find an answer through Google or through here - but I figure someone might have some insight as to the limitations.

This is using DAO 3.6 in VB6.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

陌生 2024-08-11 11:27:31

这有点hackey,但您可以在将文件打开为更友好的扩展名之前以编程方式重命名该文件。只需保留旧的扩展,以便在完成后将其设置回来。

It's a bit hackey, but you could programatically rename the file before opening it to a more friendly extension. Just keep the old extension around so you can set it back when you are done.

野却迷人 2024-08-11 11:27:31

这并不完全是您所说的情况,但在阅读本文时,在“原因”部分中,有关某些不支持长文件名的驱动程序的信息似乎适用,因为这不是 8.3 格式。

http://social.technet.microsoft.com/ Search/en-US?query=3011&ac=8

因此,您需要重命名文件或使用其他方法加载数据(例如使用 StreamReader)。就我个人而言,我会重命名该文件。那就容易多了。

This isn't exactly the situation you're talking about, but in reading this, in the CAUSE section, the information about some drivers not supporting long filenames looks like it would apply, since this is not in an 8.3 format.

http://social.technet.microsoft.com/Search/en-US?query=3011&ac=8

So, you'd need to rename the file OR use another method to load the data (such as using a StreamReader). Personally, I'd rename the file. It'd be much easier.

另类 2024-08-11 11:27:31

为什么不直接使用短文件名呢?它不会包含超过一个句点。只需从 Karl E Peterson 的优秀网站(它有一个GetShortPathName API 调用的包装方法)。

我想该卷可能不支持短文件名(它是可选)。

Why not just use the short file name instead? It won't contain more than one period. Just drop in the CFileInfo class from this offering from Karl E Peterson's excellent site (it has a wrapper method for the GetShortPathName API call).

I suppose the volume might not support short file names (it's optional).

彩扇题诗 2024-08-11 11:27:31

您需要为导入文件创建 schema.ini 文件,或者将扩展名添加到 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Text\Format 注册表项,以便 ADO 知道如何解析该文件。有详细的解释 http://msdn.microsoft.com/en-我们/library/ms974559.aspx

You need to either create a schema.ini file for your import file, or add the extension to the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Text\Format registry key so ADO knows how to parse the file. There is a detailed explanation at http://msdn.microsoft.com/en-us/library/ms974559.aspx

美人骨 2024-08-11 11:27:31

我对此不太确定,因为自从 DAO 在 VB6 中过时以来我就没有太多使用它了。我知道 Jet 的规则在 OLE DB 提供程序、ODBC 驱动程序和 DAO 之间可能非常不同。

您是否尝试过替换“.”这些文件名中的字符由“#”字符组成?或者也许只是最后一个?就在您的 SQL 语句文本中。

I'm not certain about this because I haven't used DAO much since it became obsolete in VB6. I know that Jet's rules can be very different going between the OLE DB Provider, ODBC Driver, and DAO.

Have you tried replacing the "." characters in those file names by "#" characters? Or maybe just the last one? Just in your SQL statement text.

甩你一脸翔 2024-08-11 11:27:31

据我所知,你的第二行代码不能返回任何内容!

Set db = OpenDatabase("SELECT TOP 1 * FROM [" & fileName & "];")

您无法使用 SELECT 指令打开数据库!你的代码应该看起来像

Set db = DBEngine.Workspaces(0).OpenDatabase(filenamne)

According to me, your second line of code cannot return anything!

Set db = OpenDatabase("SELECT TOP 1 * FROM [" & fileName & "];")

You cannot open a database with a SELECT instruction! Your code shouls look like

Set db = DBEngine.Workspaces(0).OpenDatabase(filenamne)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文