这是我的代码
SqlCommand cmd = new SqlCommand("SELECT Meeting.StartPlan " +
"FROM Meeting " +
"INNER JOIN meetingWho ON Meeting.meetingID = meetingWho.meetingID" +
" and Who= '"+ Username +"' ", con);
SqlDataReader read = cmd.ExecuteReader();
if (read.HasRows)
{
while (read.Read())
{
Console.WriteLine("{0}/t{1}", read.GetInt32(0), read.GetString(1));
if (e.Day.DayNumberText == "read.GetInt32(0)")
{
e.Cell.BackColor = System.Drawing.Color.Red;
}
}
}</i>
并且在此行显示错误
Console.WriteLine("{0}/t{1}", read.GetInt32(0), read.GetString(1));
我该怎么做才能解决这个问题?
答案 0 :(得分:2)
read.GetString(1)
会抛出此错误,因为在SELECT
语句中,您只查询单个列。所以没有索引为1的列。
答案 1 :(得分:1)
您在选择
中只有一列