tags:

views:

298

answers:

1

Is there a way to insert a row using ADO.Net without filling the dataset or specifying the columns? My datasets may be large, so I don't want to load them just to add a row. I know I can insert using an adapter and specifying the columns, but I'll need to do this for many tables so I don't want to create custom code for handling each different table.

+2  A: 

Load your table into an ADO.NET DataSet using a query like this:

select * from myTable where (1=0)

This will give you a zero-row dataset.

Then add your row to the dataset and get the adapter to save it for you.

codeulike