public void showDbList() { if (conn == null) { return; } tblDb.Controls.Clear(); using (SqlDataReader reader = rawQuery("SELECT name FROM SysDatabases where sid<>0x01 ORDER BY Name")) { while (reader.Read()) { String tableName = reader.GetString(0); CtlDB ctl = new CtlDB(tableName); tblDb.Controls.Add(ctl); ctl.OnBackupClicked += Ctl_OnBackupClicked; } } }
private void Ctl_OnBackupClicked(object sender, EventArgs e) { CtlDB ctl = sender as CtlDB; String dbname = ctl.dbname; runAsync(() => { String backPath = Path.Combine(Environment.CurrentDirectory, dbname); if (!Directory.Exists(backPath)) { Directory.CreateDirectory(backPath); } String backName = Path.Combine(backPath, Program.toTimeStamp(DateTime.Now) + ".dbk"); doBackup(dbname, backName); return "存档写入成功"; }); btnRefreshSave_Click(sender, e); }