如何查找受查询影响的行数 [英] How to find number of row affected by query

查看:76
本文介绍了如何查找受查询影响的行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的代码中,我想查找有多少行受查询影响,并且动态分配的数量为数组rawData



我有什么试过:



In the following code i want to find how many number of rows are affected by query and that dynamically assigned size to array rawData

What I have tried:

OleDbConnection con = (new DABasis()).getConnect();
         OleDbCommand cmd = con.CreateCommand();
         con.Open();
         cmd.CommandText = ("select * from KnowledgeTB");
         OleDbDataReader Reader = cmd.ExecuteReader();
         //if (Reader.HasRows)
         //    Reader.Read();
         int count= 0;
         count = Reader;
    //  int cnt = int.Parse(count);

         int[][] rawData = new int[count][];
         while (Reader.Read())
         {

             int db_data = Reader.GetInt32(3);
         //    rawData[i] = new int[] { i, db_data };
             rawData[i] = new int[] { i, db_data };
             i = i + 1;
         }


         cmd.Dispose();
         con.Close();

推荐答案

无。 SELECT操作不会影响任何行 - 它们只返回您指定的数据。

在这种情况下,它将返回KnowledgeTB表的所有行和所有列,因此表中的行数将为告诉你。但是,由于您使用的是OleDbDataReader,因此无法判断Read操作是异步的行数 - 当您调用Read时,它会从数据源逐个读取每一行。
None. SELECT operations do not affect any rows - they just return the data you specify.
In this case, it will return all rows and all columns for the KnowledgeTB table, so the number of rows in the table will tell you. But since you are using a OleDbDataReader you can't tell how many rows that is as the Read operation is asynchronous - it fetches each row one-by-one from the datasource when you call Read.


这篇关于如何查找受查询影响的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆