public CompanyInfoResponseModel GetCompanyDetails() { CompanyInfoResponseModel model = new CompanyInfoResponseModel(); using (connection = new MySqlConnection(conString)) { string xQry = "select * from setup_companyinfo"; connection.Open(); MySqlCommand comm = new MySqlCommand(xQry, connection); MySqlDataReader reader = comm.ExecuteReader(); while (reader.Read()) { model = new CompanyInfoResponseModel() { CompanyTitle = reader.GetString("companytitle") }; } connection.Close(); } return(model); }
public void BackUpDatabase(string file) { CompanyInfoResponseModel response = xDb.GetCompanyDetails(); string xCompanyName = response.CompanyTitle; string xCurrentDateTime = DateTime.Now.ToString("ddMMMMyyyy_h_mm_tt"); string xFileName = file + "\\" + xCompanyName + "_" + xCurrentDateTime + ".sql"; using (xDb.connection = new MySqlConnection(xDb.conString)) { using (MySqlCommand cmd = new MySqlCommand()) { using (MySqlBackup mb = new MySqlBackup(cmd)) { cmd.Connection = xDb.connection; xDb.connection.Open(); mb.ExportInfo.AddCreateDatabase = true; mb.ExportInfo.ExportTableStructure = true; mb.ExportInfo.ExportRows = true; mb.ExportToFile(xFileName); xDb.connection.Close(); } } } }