Israel

Israel

  • NA
  • 1.3k
  • 204.5k

Some time the same message. Need to resolv...

Nov 7 2016 12:43 PM
Hi,
I wrote these codes but why some time I receive this message and how can to resolv it please forever:
The connection was not closed. The connection's current state is open. 
 
conn.Open();
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select * from cadastramento order by ID";
cmd.ExecuteNonQuery();
DataTable dt = new DataTable();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.Fill(dt);
conn.Close();
dGVCons.DataSource = dt;
dGVCons.CurrentCell = dGVCons.Rows[dGVCons.Rows.Count - 1].Cells[0];
 

Answers (5)