Click here to Skip to main content
15,796,025 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
how backup database with close project or form

bool close = Convert.ToBoolean(this.Close());
if (close = true)
string Query2 = "Backup Database HNH To Disk ='" + @"\\Backup" + dt + ".bak" + "'";

What I have tried:

how backup database with close project or form
Updated 26-Jul-22 5:16am
0x01AA 26-Jul-22 10:20am    
Personally I would move that job to windows task scheduler. Like this you can schedule regular backups. And depending on your needs you can also invoke the scheduler task programmatically.

1 solution

Erm ... Close doesn't return anything - it's a void method: Form.Close Method (System.Windows.Forms) | Microsoft Docs[^] so that code probably won't even compile.

If you want to do something when a form closes, handle the FormClosing event[^] and do it there.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900