简体   繁体   English

ADO.Net插入强类型的行,而无需将数据集加载到内存

[英]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? 有没有一种方法可以使用ADO.Net插入行而不填充数据集或指定列? 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: 使用如下查询将表加载到ADO.NET数据集中:

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. 然后将您的行添加到数据集中,并获取适配器为您保存它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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