Reputation: 10236
Hello friend how can I perform Bulk insert into MDB from Dataset. 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
Or is there any other way to update Ms Access table Faster with multiple records Thanks All
Upvotes: 3
Views: 4174
Reputation: 28059
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);
}
}
}
Upvotes: 0
Reputation: 19598
Yes it is possible. More Info :INSERT INTO Statement (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.
Upvotes: 4