M
mycwcgr_new
Unregistered / Unconfirmed
GUEST, unregistred user!
在C#中,OleDbDataReader 能否返回挑选记录的总数?
下面的程序使用OleDbDataReader查询数据库中特定的记录,在执行OleDbDataReader reader=myCommand.ExecuteReader();后
我想知道一共查询到了多少条记录,请问OleDbDataReader是否有一个属性可以返回挑选记录的总数?
public ArrayList GetUserList()
{
ArrayList userList=new ArrayList(10);
try
{
ConstClass.databaseConnect.Open();
OleDbCommand myCommand=new OleDbCommand();
myCommand.Connection=ConstClass.databaseConnect;
myCommand.CommandText="select * from usertable";
OleDbDataReader reader=myCommand.ExecuteReader();
while (reader.Read())
{
userList.Add(reader["UserName"].ToString());
}
reader.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
ConstClass.databaseConnect.Close();
}
return userList;
}
下面的程序使用OleDbDataReader查询数据库中特定的记录,在执行OleDbDataReader reader=myCommand.ExecuteReader();后
我想知道一共查询到了多少条记录,请问OleDbDataReader是否有一个属性可以返回挑选记录的总数?
public ArrayList GetUserList()
{
ArrayList userList=new ArrayList(10);
try
{
ConstClass.databaseConnect.Open();
OleDbCommand myCommand=new OleDbCommand();
myCommand.Connection=ConstClass.databaseConnect;
myCommand.CommandText="select * from usertable";
OleDbDataReader reader=myCommand.ExecuteReader();
while (reader.Read())
{
userList.Add(reader["UserName"].ToString());
}
reader.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
ConstClass.databaseConnect.Close();
}
return userList;
}