many thanks to everyone. I believe I have resolved this (too many EndExecuteNonQuery lurking in the code. :-)
The method 'EndExecuteNonQuery' cannot be called more than once for the same execution.

Hi,
I am trying to create a program that will back up a database, and then restore this backup to a different name (orginalDatasbaseName_training).
The backup part works Ok, but when this finishes I get a "'EndExecuteNonQuery' cannot be called more than once", and when the Training creation process starts also, then I get the same message.
I've tried adding a "command.EndExecuteNonQuery" at the end of the backup section, and putting the training creation put into its own connection ( and the opening and closing of a connection after each of the training procedures SQL lines), but I still get the same error.
214689-creatingtrainingdb.txt
Many Thanks
Nb: file attached as I was unable to copy code into Post.
3 answers
Sort by: Newest
-
Gerald Oakham 81 Reputation points
2022-06-24T11:20:13.74+00:00 Hi,
but after the backup it produces the "'EndExecuteNonQuery' cannot be called more than once for the same execution." message , and if an option is ticked, when its tried to recover the newly created backup into another database, it fails with the same message.Olaf Helper 27,211 Reputation points2022-06-24T10:44:01.857+00:00 I've tried adding a "command.EndExecuteNonQuery" at the end of the backup section,
And what should that be good for?
The execution automatically ends when the backup has finished.