简体   繁体   中英

ADO.Net Insert strongly-typed Row without loading dataset to memory

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM