在 C# 3.5 中生成 dBase II DBF 文件

发布于 2024-09-25 18:18:08 字数 184 浏览 8 评论 0原文

我正在生成 dbf 文件以导入到仅接受 dBase II 或 III 的旧系统。我的应用程序是.Net 3.5。我最初开始使用这个组件 VFPOLEDB.1,但它只生成 dBase V 格式的 dbf 文件,该格式不向后兼容。

任何人都知道在 dBase II 或 III 中生成 de dbf 文件的组件或驱动程序

谢谢

I'm generating dbf file to get imported to legacy systems that only accepts dBase II OR III. My aplication is .Net 3.5. I initially started working with this component VFPOLEDB.1 but it only generate dbf files in dBase V format which isn't backwards compatibily.

Anyone knows a component or driver to generate de dbf file in dBase II or III

Thanks

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

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

发布评论

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

评论(3

明媚如初 2024-10-02 18:18:08

尝试发出调用来执行打开文件的脚本,然后执行

COPY TO {some file} type FOX2X

这应该会得到输出...

还有另一篇类似的文章,所有内容都是通过 VFPOleDB 通过 C# 完成的,我'我会尝试找到它...是的,感谢 @DaveB,这里是他在 Create .DBF in C# code that url 中的帖子片段来自 Excel(VFP 或非 VFP)

 string connectionString = @"Provider=VFPOLEDB.1;Data Source=C:\YourDirectory\"; 

    using (OleDbConnection connection = new OleDbConnection(connectionString)) 
    { 
        using (OleDbCommand scriptCommand = connection.CreateCommand()) 
        { 
            connection.Open(); 

            string vfpScript = @"USE TestDBF 
                                 COPY TO OldDBaseFormatFile TYPE Fox2x 
                                USE"; 

            scriptCommand.CommandType = CommandType.StoredProcedure; 
            scriptCommand.CommandText = "ExecScript"; 
            scriptCommand.Parameters.Add("myScript", OleDbType.Char).Value = vfpScript; 
            scriptCommand.ExecuteNonQuery(); 
        } 
    } 

最初的帖子是为了让某人能够以 Excel 格式打开文件。

Try issuing a call to execute a script that opens the file, then does

COPY TO {some file} type FOX2X

that should get you the output...

There was another post of a similar all being done via C# through the VFPOleDB and I'll try to find it... Yup, and with credit to @DaveB here's a snippet of his post in Create .DBF in C# code that is readable from Excel (VFP or not)

 string connectionString = @"Provider=VFPOLEDB.1;Data Source=C:\YourDirectory\"; 

    using (OleDbConnection connection = new OleDbConnection(connectionString)) 
    { 
        using (OleDbCommand scriptCommand = connection.CreateCommand()) 
        { 
            connection.Open(); 

            string vfpScript = @"USE TestDBF 
                                 COPY TO OldDBaseFormatFile TYPE Fox2x 
                                USE"; 

            scriptCommand.CommandType = CommandType.StoredProcedure; 
            scriptCommand.CommandText = "ExecScript"; 
            scriptCommand.Parameters.Add("myScript", OleDbType.Char).Value = vfpScript; 
            scriptCommand.ExecuteNonQuery(); 
        } 
    } 

The original post was for someone to be able to open the file in Excel format.

冷情妓 2024-10-02 18:18:08

我记得几年前就尝试过做这件事,但失败了。我的解决方案是采用现有的 dBase II 文件,清空所有数据,并保留该空文件作为我需要创建新数据库时的模板。

I remember trying to do this very thing several years ago and failing. My solution was to take an existing dBase II file, empty all data, and keep that empty file as a template for when I needed to create a new database.

注定孤独终老 2024-10-02 18:18:08

ESRI 的 Shapefile 格式使用 dBase III 来存储属性数据。 SharpMap 项目中有一个不错的实现,您应该能够独立使用它(不过要注意许可证:它是 LGPL)。

http://code.google .com/p/sharpmapv2/source/browse/trunk/SharpMap.Data.Providers/ShapeFileProvider/DbaseFile.cs

ESRI's Shapefile format uses dBase III for storing attribute data. There's a decent implementation in the SharpMap project which you should be able to use independently (careful of the license, though: it's LGPL).

http://code.google.com/p/sharpmapv2/source/browse/trunk/SharpMap.Data.Providers/ShapeFileProvider/DbaseFile.cs

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