Inserting datarow into Access table?

  • Thread starter Thread starter VMI
  • Start date Start date
V

VMI

Assuming I have a datarow (or a datarow collection), would it possible to
create an Access table and dump the datarow(s) into that Access table? I
wouldn't even need to create the fields in the Access table since the
datarow contains the exact table schema. I'm currently taking each datarow
and creating an Insert statement that i then run against Access.
 
Hi,

What if you add these rows to a DataTable, then configure an
OleDbDataAdapter with a proper connection and insert command, and then just
invoke Update on the pre-configured data adapter?
You can go even further and utilize the CommandBuilder class to generate the
insert command automatically based on the select command from the target
table.

Hope this helps.
 
I'm not sure I completely understand .
What would the Insert command in the oleDbAdapter look like? Once I have my
DataTable with the all the rows, what would I need to do next?

Thanks.

Dmitriy Lapshin said:
Hi,

What if you add these rows to a DataTable, then configure an
OleDbDataAdapter with a proper connection and insert command, and then
just invoke Update on the pre-configured data adapter?
You can go even further and utilize the CommandBuilder class to generate
the insert command automatically based on the select command from the
target table.

Hope this helps.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

VMI said:
Assuming I have a datarow (or a datarow collection), would it possible to
create an Access table and dump the datarow(s) into that Access table? I
wouldn't even need to create the fields in the Access table since the
datarow contains the exact table schema. I'm currently taking each
datarow and creating an Insert statement that i then run against Access.
 
Back
Top