public static bool Attach(string DataPath, string datafile,string dbname)
{
SqlCommand AttachDbCommand= new SqlCommand() ;
//Проствляем коннесшн
AttachDbCommand.Connection = sqlConnectionK9static;
AttachDbCommand.CommandText = @"sp_attach_single_file_db @dbname = '"+dbname+@"', @physname = '"+Business.clsBusinessComputerSettings.Instance().InternalServerImportExportDirectory+@"\"+datafile+"'";
//Удаляем возможно оствшийся от такого же аттача log
DeleteLog(DataPath, datafile);
try
{
AttachDbCommand.ExecuteNonQuery();
}
catch(Exception exc)
{
exc.ToString();
clsMessages.ShowErrorMessage(K9.ErrorMessageCode.ERROR_EXPORT_CANTATTACHEDUMMY);
System.Windows.Forms.MessageBox.Show(exc.ToString());
return false;
}
return true;
}
|