2

我觉得这很奇怪,我有这个代码:

string getBatchesQuery = "SELECT DISTINCT CONVERT(VARCHAR(8), time, 4) AS Batch FROM Calls ORDER BY Batch";
SqlCommand getBatchesQueryCom = new SqlCommand(getBatchesQuery, connection);

SqlDataReader getBatchesQueryReader = myCom.ExecuteReader();

List<string> allBatches = new List<string>();

while (getBatchesQueryReader.Read())
{

    allBatches.Add(getBatchesQueryReader["Batch"].ToString());

}
getBatchesQueryReader.Close();

现在怎么可能Batch不存在呢?也许是因为我这样命名它?

我应该怎么办?

4

1 回答 1

2

该列不存在,因为您运行了错误的命令。更改myComgetBatchesQueryCom

SqlDataReader getBatchesQueryReader = getBatchesQueryCom.ExecuteReader();
于 2012-11-25T15:55:44.763 回答