[英]Is it possible to perform Bulk Insert in MSAccess
Hello friend how can I perform Bulk insert into MDB from Dataset. 您好朋友,我如何从数据集执行批量插入MDB。 till now I have done something like this
到现在为止,我已经做了这样的事情
string InsertBulkQry = "INSERT INTO Table1 SELECT * FROM table IN "
+MYDs.Tables[0];
I am using C# and VS 2005 我正在使用C#和VS 2005
Or is there any other way to update Ms Access table Faster with multiple records Thanks All 还是有其他方法可以更快地更新具有多个记录的Ms Access表感谢所有
Yes it is possible. 对的,这是可能的。 More Info : INSERT INTO Statement (Microsoft Access SQL)
更多信息: INSERT INTO语句(Microsoft Access SQL)
var cmdText = "INSERT INTO Table1 SELECT * FROM Table2";
var command = new OleDbCommand(cmdText, connection);
command.ExecuteNonQuery();
Not tested, it should work. 未经测试,它应该可以工作。 Or you can create a query in Access and Execute it from C# code.
或者,您可以在Access中创建查询并通过C#代码执行它。
This should work: 这应该工作:
using System.Runtime.InteropServices;
using Access = Microsoft.Office.Interop.Access;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
var access = new Access.Application();
access.OpenCurrentDatabase(@"C:\whatever.mdb");
access.DoCmd.RunSQL("INSERT INTO Table1 SELECT * FROM Table2");
access.CloseCurrentDatabase();
Marshal.ReleaseComObject(access);
}
}
}
这是解释的MS Access INSERT SQL命令 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.