I have an app that uses SQL with access. I've been fine through the whole thing until I tried using the UPDATE command. When it gets to ExecuteNonQuery () it tells me that there is no open connection. A few lines before it though I can access the database. I went through the query builder and it generated an update statement. Where am I going wrong? Here's my code:
oleDbDataAdapte r1.SelectComman d.CommandText = "SELECT Count FROM Choices WHERE Title = '" + title + "' AND Choice = '" + choice + "'";
oleDbDataAdapte r1.Fill(dataSet 1);
DataTable dataTable = dataSet1.Tables[0];
int count = Int32.Parse(dat aTable.Rows[0][4].ToString());
count++;
oleDbDataAdapte r1.UpdateComman d.CommandText = "UPDATE Choices SET Count = '" + count.ToString( ) + "' WHERE Title = '" + title + "' AND Choice = '" + choice + "'";
oleDbDataAdapte r1.UpdateComman d.ExecuteNonQue ry();
oleDbDataAdapte r1.SelectComman d.CommandText = "SELECT Count FROM Choices WHERE Title = '" + title + "' AND Choice = '" + choice + "'";
oleDbDataAdapte r1.Fill(dataSet 1);
DataTable dataTable = dataSet1.Tables[0];
int count = Int32.Parse(dat aTable.Rows[0][4].ToString());
count++;
oleDbDataAdapte r1.UpdateComman d.CommandText = "UPDATE Choices SET Count = '" + count.ToString( ) + "' WHERE Title = '" + title + "' AND Choice = '" + choice + "'";
oleDbDataAdapte r1.UpdateComman d.ExecuteNonQue ry();
Comment