问题描述
我的问题与高效方式完全相同批量插入Dbase(.dbf)文件中-是否有有效的方法批量插入dbase IV dbf文件?源数据来自SQL Server2012.我可以使用Visual FoxPro,但我想通过C#以编程方式进行此操作.
My question is pretty much the exact same as Efficient way to bulk insert into Dbase (.dbf) files - Is there an efficient way to bulk insert into dbase IV dbf files? The source data is coming from SQL Server 2012. I have Visual FoxPro available but I'd like to do this programatically from C#.
推荐答案
如注释中所述,如果在VFP中,您应该可以通过
As mentioned in comment, if in VFP, you should be able to do quite easily by means of
nHandle = sqlconnect( "connection string to your database" )
sqlexec( nHandle, "select * from YourTable", "localResultSetInVFP" )
*/ At this point, the current work area is the "localResultSetInVFP"
copy to SomeOtherTable <== this actually creates the final DBF for you locally.
我能想到的唯一可行的方法如下.
The only other way I can think of that MAY work is as follows.
Create a database CONTAINER in VFP.
Create a connection to the SQL Database.
Create a REMOTE VIEW to the table(s) in the SQL Database.
然后,在C#中使用VFP OleDB创建到路径的连接,并包含.DBC数据库名称.然后,您可能可以根据VIEW名称进行选择...,希望.DBC可以启动,并打开/获取SQL连接句柄,运行远程视图查询,然后将所有数据返回给您.
Then, in C# using the VFP OleDB, create a connection to the path AND include the .DBC database name. Then you might be able to do a select based on the VIEW name... and hopefully the .DBC will kick in, and open / get SQL connection handle, run the remote view query and return all the data to you.
让我知道此指南是否对您有用.
Let me know if this guidance works for you.
,这也是一个简单的创建表"命令.
One example to create table from existing within VFP's OleDB this also a simple "Create Table" command.
一个很好的构建示例命令和参数一次,然后对每一行执行并执行插入
希望上述链接向您展示了各种各样的方法,可用于创建和插入DBF文件.
Hopefully the above links show you a wide variety to implement creating and inserting into DBF files.
您可以从其他数据库连接(例如SQL,MySQL等)创建任何查询,并使用datareader或dataadapter.fill从其中一个下载,循环进入VFP循环插入并更新参数...例子,希望大多数例子可以清楚地理解.
You can create whatever query from other database connection such as SQL, MySQL, etc and use a datareader or dataadapter.fill to download from one, loop into the VFP cycle insert and update the parameters... You'll see the examples and hopefully most are clear to follow.
这篇关于批量插入Dbase IV(.dbf)文件的有效方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!