OleDbDataReader检索特定的行值(CSHTML)

时间:2013-12-19 13:42:52

标签: c# html razor oledbdatareader

我正试图以特定的顺序从读者中提取价值。我有很多代表,需要将它们组合到他们的区域中,这样我就可以对它们进行总计。

我有一个本地mdb的连接,暂时可以正常工作。在其他地方,我循环阅读器以获取数据。像这样......

   var thisConnection = new OleDbConnection(@"Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\SALES.mdb");
thisConnection.Open();
var thisCommand = thisConnection.CreateCommand();
thisCommand.CommandText = "SELECT `Rep Name`, Sum(`Budget`) AS xyValues_Bud FROM `Invoices` GROUP BY `Rep Name`;";
OleDbDataReader thisReader = thisCommand.ExecuteReader();

.....

@while(thisReader.Read())
{
   @thisReader["Rep Name"] <text>,</text> @thisReader["xyValues_Bud "] 
}

但是我想把它们按顺序拉出来让我们说... SouthRep,EastRep,WestRep,NorthRep

所以我需要像...这样的东西。

@thisReader["Rep Name"] = "SouthRep" {<text>SouthRep,</text> @thisReader["xyValues_Bud "] }
@thisReader["Rep Name"] = "EastRep" {<text>EastRep,</text> @thisReader["xyValues_Bud "] }
....

我考虑过创建一个循环并选择我想要的条目,但必须有一个更简单的方法。

谢谢

0 个答案:

没有答案
相关问题