考虑一个连接到 SQL Server 2008 数据库并运行 SQLSELECT
语句的 Winforms 应用程序:
string myConnectionString = "Provider=SQLOLEDB;Data Source=hermes;Initial Catalog=qcvaluestest;Integrated Security=SSPI;";
string mySelectQuery = "SELECT top 500 name, finalconc from qvalues where rowid between 0 and 25000;";
OleDbConnection myConnection = new OleDbConnection(myConnectionString);
OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection);
myCommand.Connection.Open();
OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
如何将查询结果读入列表?