如何手工遍历数据集中的数据,一行一行的那种?

sogasoga 2003-05-13 03:57:55
如何手工遍历数据集中的数据,一行一行的那种?还有如何在ds.Tables["..."].Columns里添加一个列,据个例子吧,谢谢。
...全文
42 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
Knight94 2003-05-16
  • 打赏
  • 举报
回复
To sqldatareader如何读完一行手动跳到下一行呢?谢谢!

在调用一下其的Read()方法,如果成功,读取记录数据;否则,已经没记录了。
shenshenxiaoyuan 2003-05-15
  • 打赏
  • 举报
回复
细心读贴
sogasoga 2003-05-15
  • 打赏
  • 举报
回复
sqldatareader如何读完一行手动跳到下一行呢?谢谢!
Knight94 2003-05-14
  • 打赏
  • 举报
回复
To 你这种方法如何手动控制阿,我想处理完自己手动下移一行的,比如next这种有嘛?

使用SqlDataReader

To SqlDataReader 用的时候不正常,总是跳到catch中去也。

最好给大家看看你怎么调用,SqlDataReader本身没有问题。
Knight94 2003-05-14
  • 打赏
  • 举报
回复
To 你这种方法如何手动控制阿,我想处理完自己手动下移一行的,比如next这种有嘛?

使用SqlDataReader

To SqlDataReader 用的时候不正常,总是跳到catch中去也。

最好给大家看看你怎么调用,SqlDataReader本身没有问题。
sogasoga 2003-05-13
  • 打赏
  • 举报
回复
如何动态编辑一个表格呢,比如dataset读入一个表格后,我便历每一行的数值计算完成后想对表格天一个列来保存计算结果,然后返回出来,怎么做呢?我对c#还不熟练,谢谢!
sogasoga 2003-05-13
  • 打赏
  • 举报
回复
to fupip(小贝)和 net_lover(孟子E章) :你这种方法如何手动控制阿,我想处理完自己手动下移一行的,比如next这种有嘛?
to all above:SqlDataReader 用的时候不正常,总是跳到catch中去也。
贝贝壳壳 2003-05-13
  • 打赏
  • 举报
回复
foreach(DataRow d in ds.Tables["..."].Rows)
{

}
孟子E章 2003-05-13
  • 打赏
  • 举报
回复
SqlDataReader myReader = logoCMD.ExecuteReader(CommandBehavior.SequentialAccess);

while (myReader.Read())
{
// Get the publisher id, which must occur before getting the logo.
pub_id = myReader.GetString(0);

// Create a file to hold the output.
fs = new FileStream("logo" + pub_id + ".bmp", FileMode.OpenOrCreate, FileAccess.Write);
bw = new BinaryWriter(fs);

// Reset the starting byte for the new BLOB.
startIndex = 0;

// Read the bytes into outbyte[] and retain the number of bytes returned.
retval = myReader.GetBytes(1, startIndex, outbyte, 0, bufferSize);

// Continue reading and writing while there are bytes beyond the size of the buffer.
while (retval == bufferSize)
{
bw.Write(outbyte);
bw.Flush();

// Reposition the start index to the end of the last buffer and fill the buffer.
startIndex+= bufferSize;
retval = myReader.GetBytes(1, startIndex, outbyte, 0, bufferSize);
}

// Write the remaining buffer.
bw.Write(outbyte);
bw.Flush();

// Close the output file.
bw.Close();
fs.Close();
}
孟子E章 2003-05-13
  • 打赏
  • 举报
回复
Do While myReader.Read()
'.......
Loop

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧