ADO.NET问题

编程入门 行业动态 更新时间:2024-10-10 16:20:35
本文介绍了ADO.NET问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

大家好, 我有一个问题...我一次读取了20000行,但是我只使用了一行,经过处理后,我又使用了另一行. 我该怎么办? 请回复. 看到这里:

Hi everybody, I have one problem... I read 20000 rows at a time, but I use only one row and after processing, I use another row. How can I do this? Please reply. See here:

con = new SqlConnection(nrdet); SqlDataAdapter da = new SqlDataAdapter("select E1,SM1,R1,E2,SM2,R2,E3,SM3,R3,E4,SM4,R4,E5,SM5,R5,E6,SM6,R6,E7,SM7,R7,E8,SM8,R8,E9,SM9,R9,E10,SM10,R10 From TOTAL_NR WHERE SCHEME=''" + DropDownList1.SelectedItem.Text + "'' AND YR=''" + DropDownList2.SelectedItem.Text + "'' AND RESULT=3", con); DataSet ds = new DataSet(); da.Fill(ds);

实际上,这里有2000行,但是我要逐行比较行. 我先使用E1,SM1,R1值,然后比较E2,SM2,R2之后的结果...

Actually, here there are 2000 rows, but I compare rows one after another. I use E1,SM1,R1 values first I compare those results after E2,SM2,R2.....

推荐答案

您可以遍历结果集吗? br/> 我可能没有正确理解您的问题-也许您需要在此处发布一些代码. You can loop through the result set? I may not have understood your question properly - maybe you need to post some code here.

获取对DataTable对象的引用并遍历行集合 Get a reference to the DataTable object and loop through the rows collection DataSet ds = new DataSet(); da.Fill(ds); DataTable dt = ds.Tables[0]; foreach(DataRow dr in dt.Rows) { // Now use the dararow object to access your column fields if (Convert.ToInt32(dr["YourIntegerFieldName"]) == WhateverTest) { // Do something? } }

hmm,当您使用数据集时,一次获取所有记录并将其保留在内存中,而将它们保留在内存中时,您将比较行中的值, 但我想建议您使用一次仅获取一条记录的SqlDataReader,这在性能方面会很好,但是如果您要使用断开连接的数据访问,则需要在进程完成时保持db连接,或编辑记录中的数据,数据集就可以了. 但是在这种情况下,使用数据集意味着您可以在内存中保留20000条记录. hmm when you use the dataset you take all the records at once and keep them in the memory , while keeping them in memory you compare the values in the row, but i would like to suggest you to use the SqlDataReader which takes only one record at a time , it will be good in performance wise , but u need to keep the db connection while process completes , if you want to use a disconnected data accessing, or editing data in the record, dataset is good . but in this case using dataset means you keep 20000 records in memory.

更多推荐

ADO.NET问题

本文发布于:2023-11-09 11:52:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1572306.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ADO   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!