Skip to content
Advertisement

Tag: sqlconnection

‘ExecuteNonQuery requires an open and available Connection. The connection’s current state is closed.’ – C#

The code: This error shows up when I click the save button: System.InvalidOperationException: ‘ExecuteNonQuery requires an open and available Connection. The connection’s current state is closed.’ I am using the using keyword, if I’m correct doesn’t using automatically opens and closes the sqlConnection? If so, why does it returns an error that I need an open and available connection for

Update SQL table using C#

I’m trying to update EpisodeId no:117 in the Episode table and it executes successfully but when I check the table it is not updated. int episode Id = 117; Answer There are some issues with your SQL update statement.Look at following for reference to Update Statement in SQL LINK There is also an easier way to add the parameters using

C# SQLConnection.Open() hangs, with no exception

I am using C# in Visual Studio 2019, with Xamarin.Forms, and SQl in SSMS 2018 and have the below code (where [] is used to replace unneccessary information) When I run this, it hangs indefinitely at connection.Open(). Debug mode continues to run and appears to move on from Connection.Open(), but never reaches the next line. I have attempted this with

Advertisement