Hello!
The program throws the exception on the last line below:
An unhandled exception of type System.InvalidOperationException' occurred in myprog.exe
Additional information: There is already an open DataReader associated with this Connection which must be closed first.
Is there anything I am missing that would work?
----
string sql = "select * from GroupCalendar";
SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
conn.Open();
SqlCommand myCommand = new SqlCommand(sql, conn);
SqlDataReader myReader = myCommand.ExecuteReader();
if (myReader.HasRows)
while (myReader.Read())
{
sql = "update calendar set groupid = " + myReader["igroupid"];
sql += " where appointment_id = " + myReader["iappointmentID"];
myCommand.CommandText = sql;
myCommand.ExecuteNonQuery(); <--------------
The program throws the exception on the last line below:
An unhandled exception of type System.InvalidOperationException' occurred in myprog.exe
Additional information: There is already an open DataReader associated with this Connection which must be closed first.
Is there anything I am missing that would work?
----
string sql = "select * from GroupCalendar";
SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
conn.Open();
SqlCommand myCommand = new SqlCommand(sql, conn);
SqlDataReader myReader = myCommand.ExecuteReader();
if (myReader.HasRows)
while (myReader.Read())
{
sql = "update calendar set groupid = " + myReader["igroupid"];
sql += " where appointment_id = " + myReader["iappointmentID"];
myCommand.CommandText = sql;
myCommand.ExecuteNonQuery(); <--------------