Last post Dec 24, 2016 09:09 AM by PatriceSc
Dec 24, 2016 04:36 AM|hewawasam|LINK
con = new
dlg = new
(dlg.ShowDialog() == DialogResult.OK)
txt_backup.Text = dlg.SelectedPath;
database = con.Database.ToString();
(txt_backup.Text == string.Empty)
cmd = "BACKUP
DATABASE [" + database +
TO DISK='" +txt_backup.Text +
command = new
(con.State != ConnectionState.Open)
object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or  are not allowed. Change the alias to a valid name.
Dec 24, 2016 09:09 AM|PatriceSc|LINK
On which line? As this is a SQL side error the first logical move would be to just look at the value for the cmd variable to spot a possible problem in the SQL statement (could it be that the database name is empty?).
Not directly related but:
is for Windows app. It won't work on a real web server (this code runs server side)
- never use an empty catch clause. You never really want to just ignore all errors.
- not sure about the exact need but you should have least an automatic backup planned on a regular basis in addition to manual backups (never rely only on manually triggered backups).