我觉得这很奇怪,我有这个代码:
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
不存在?也许是因为我这样命名?
我该怎么办?
答案 0 :(得分:2)
该列不存在,因为您运行的命令错误。将myCom
更改为getBatchesQueryCom
。
SqlDataReader getBatchesQueryReader = getBatchesQueryCom.ExecuteReader();