C# ExecuteNonQuery requires an open and available Connection. The connection's current state is closed?

You need to open and close the connection like so.

You need to open and close the connection like so using (OleDbConnection connection = new OleDbConnection(connstr)) { connection.Open(); using (OleDbCommand commands = connection.CreateCommand()) { //snip } }.

You haven't called connection.Open() to open the conenction you are trying to use.

Your connection is closed, try the Open command and handle the errors if any. Using (OleDbConnection connection = new OleDbConnection(connectionString)) { // The insertSQL string contains a SQL statement that // inserts a new row in the source table. OleDbCommand command = new OleDbCommand(insertSQL); // Set the Connection to the new OleDbConnection.Command.

Connection = connection; // Open the connection and execute the insert command. Try { connection.Open(); command.ExecuteNonQuery(); } catch (Exception ex) { Console. WriteLine(ex.

Message); } // The connection is automatically closed when the // code exits the using block. }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions