在C#3.5中生成dBase II DBF文件 [英] Generating dBase II DBF File in C# 3.5
问题描述
我正在生成dbf文件,以导入到仅接受dBase II或III的旧系统中。我的应用是.Net 3.5。我最初开始使用此组件VFPOLEDB.1,但它只会生成dBase V格式的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.
任何人都知道要生成的组件或驱动程序dBase II或III中的de dbf文件
Anyone knows a component or driver to generate de dbf file in dBase II or III
谢谢
推荐答案
尝试发出调用以执行打开文件的脚本,然后
Try issuing a call to execute a script that opens the file, then does
复制到{some file}类型FOX2X
COPY TO {some file} type FOX2X
应该会为您提供输出...
that should get you the output...
还有另一篇类似的文章,是通过VFPOleDB通过C#完成的,我将尝试找到它。 ..是的,并以@DaveB为功,这是他在以C#代码创建.DBF的代码段,该代码可从Excel(无论是否为VFP)读取)
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();
}
}
原始帖子是为了有人可以打开文件为Excel格式。
The original post was for someone to be able to open the file in Excel format.
这篇关于在C#3.5中生成dBase II DBF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!