【问题标题】:Generating dBase II DBF File in C# 3.5在 C# 3.5 中生成 dBase II DBF 文件
【发布时间】:2010-10-02 02:23:35
【问题描述】:

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

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

谢谢

【问题讨论】:

    标签: c# dbf dbase


    【解决方案1】:

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

    复制到 {some file} 类型 FOX2X

    这应该会给你输出...

    还有一篇类似的帖子正在通过 C# 通过 VFPOleDB 完成,我会尝试找到它...是的,感谢 @DaveB,这是他在 Create .DBF in C# code that is readable from Excel (VFP or not) 中的帖子的 sn-p /p>

     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 格式打开文件。

    【讨论】:

      【解决方案2】:

      我记得几年前尝试做这件事并失败了。我的解决方案是获取一个现有的 dBase II 文件,清空所有数据,并将该空文件作为模板,以便在我需要创建新数据库时使用。

      【讨论】:

        【解决方案3】:

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

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-12-06
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2015-02-09
          相关资源
          最近更新 更多