请问关于c的具体应用场景有哪些?
- 内容介绍
- 文章标签
- 相关推荐
本文共计211个文字,预计阅读时间需要1分钟。
我尝试将数据集中的数据添加到List中。这是我在C语言中实现的方法。
我试图将数据集中的数据添加到List中.这是我在C#中的功能public List<ProductsDAL> GetAllProducts(string sqlQuery) { DataSet dsinsert = GetDataSet(sqlQuery, "tblProducts"); List<ProductsDAL> bPList = new List<ProductsDAL>(); ProductsDALforeach (DataRow item in dsinsert.Tables[0].Rows) { this.Product_ID = item["Product_ID"].ToString(); this.ProductDescr= item["ProductDescr"].ToString(); bPList.Add(this); } return bPList; }
数据集中的结果如下
column1 - colum2 A 1 B 2 C 3 D 4
但我认为列表中的结果是:
column1 - colum2 D 1 D 1 D 1 D 1
当我将这组数据插入另一个数据库时,我只得到这个:
column1 - colum2 D 1
我的功能在做什么?
您需要在foreach语句中创建一个新的ProductsDAL.你刚刚更新了同一个.本文共计211个文字,预计阅读时间需要1分钟。
我尝试将数据集中的数据添加到List中。这是我在C语言中实现的方法。
我试图将数据集中的数据添加到List中.这是我在C#中的功能public List<ProductsDAL> GetAllProducts(string sqlQuery) { DataSet dsinsert = GetDataSet(sqlQuery, "tblProducts"); List<ProductsDAL> bPList = new List<ProductsDAL>(); ProductsDALforeach (DataRow item in dsinsert.Tables[0].Rows) { this.Product_ID = item["Product_ID"].ToString(); this.ProductDescr= item["ProductDescr"].ToString(); bPList.Add(this); } return bPList; }
数据集中的结果如下
column1 - colum2 A 1 B 2 C 3 D 4
但我认为列表中的结果是:
column1 - colum2 D 1 D 1 D 1 D 1
当我将这组数据插入另一个数据库时,我只得到这个:
column1 - colum2 D 1
我的功能在做什么?
您需要在foreach语句中创建一个新的ProductsDAL.你刚刚更新了同一个.
