Click here to Skip to main content
15,922,145 members
Home / Discussions / C#
   

C#

 
GeneralRe: Could not load file or assembly or one of its dependencies. The given assembly name or codebase was invalid. exception from HRESULT Pin
Marat Beiner12-Feb-11 9:10
Marat Beiner12-Feb-11 9:10 
GeneralRe: Could not load file or assembly or one of its dependencies. The given assembly name or codebase was invalid. exception from HRESULT Pin
Henry Minute12-Feb-11 9:59
Henry Minute12-Feb-11 9:59 
GeneralRe: Could not load file or assembly or one of its dependencies. The given assembly name or codebase was invalid. exception from HRESULT Pin
Marat Beiner12-Feb-11 10:39
Marat Beiner12-Feb-11 10:39 
GeneralRe: Could not load file or assembly or one of its dependencies. The given assembly name or codebase was invalid. exception from HRESULT Pin
Henry Minute12-Feb-11 12:20
Henry Minute12-Feb-11 12:20 
GeneralRe: Could not load file or assembly or one of its dependencies. The given assembly name or codebase was invalid. exception from HRESULT [modified] Pin
Marat Beiner12-Feb-11 13:59
Marat Beiner12-Feb-11 13:59 
GeneralRe: Could not load file or assembly or one of its dependencies. The given assembly name or codebase was invalid. exception from HRESULT Pin
Henry Minute13-Feb-11 1:44
Henry Minute13-Feb-11 1:44 
GeneralRe: Could not load file or assembly or one of its dependencies. The given assembly name or codebase was invalid. exception from HRESULT Pin
Marat Beiner13-Feb-11 2:01
Marat Beiner13-Feb-11 2:01 
QuestionProblem with C# code to backup sql server 2005 database Pin
M Nasir Uddin12-Feb-11 1:36
M Nasir Uddin12-Feb-11 1:36 
Hi everyone,
I have developed a desktop application. I have created a menu item to click for backup database from MS SQL Server 2005. This is why I have created a method to perform the operation. But the method is not working well. There’s something wrong in the code which I cannot recognize. Please help me to find the problem and solution as well. The method code is given bellow:

public void BackupDatabase(String databaseName, String destinationPath)
        {
            try
            {                
                Backup sqlBackup = new Backup();
                sqlBackup.Action = BackupActionType.Database;
                sqlBackup.BackupSetDescription = "ArchiveDataBase:" + DateTime.Now.ToShortDateString();
                sqlBackup.BackupSetName = "Archive";
                sqlBackup.Database = databaseName;

                BackupDeviceItem deviceItem = new BackupDeviceItem(destinationPath, DeviceType.File);
                SqlConnection sqlCon = new SqlConnection(GenericDataAccess.GetConnectionString());
                ServerConnection connection = new ServerConnection(sqlCon);

                Server sqlServer = new Server(connection);
                Database db = sqlServer.Databases[databaseName];
                sqlServer.Databases.Add(db);                

                sqlBackup.Initialize = true;
                sqlBackup.Checksum = true;
                sqlBackup.ContinueAfterError = true;

                sqlBackup.Devices.Add(deviceItem);
                sqlBackup.Incremental = false;                

                sqlBackup.ExpirationDate = DateTime.Now.AddDays(3);
                sqlBackup.LogTruncation = BackupTruncateLogType.Truncate;

                sqlBackup.FormatMedia = false;
                sqlBackup.SqlBackup(sqlServer);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n"  + ex.StackTrace);
            }
        }


And the click event from where I am calling the method is also given:

private void backupMnuItem_Click(object sender, EventArgs e)
{
            BackupData_Bl backup = new BackupData_Bl();
            backup.BackupDatabase("CFM", "D:\\TEMP");
}    

For your information (it might help you to find the problem) I have first create my database using SQL Server Management Studio. Then I’ve move the database from sql server installation location to my project directory under a folder named DB. After that I have attached the database using SQL Server Management Studio.
AnswerRe: Problem with C# code to backup sql server 2005 database Pin
Mycroft Holmes12-Feb-11 2:06
professionalMycroft Holmes12-Feb-11 2:06 
QuestionMessage Closed Pin
11-Feb-11 21:19
wenlong8811-Feb-11 21:19 
AnswerRe: Not C# question! Pin
Richard MacCutchan11-Feb-11 21:21
mveRichard MacCutchan11-Feb-11 21:21 
GeneralRe: Not C# question! Pin
OriginalGriff11-Feb-11 22:22
mveOriginalGriff11-Feb-11 22:22 
Questionhow to change the colour of buttons through timer in c# window application Pin
aeman11-Feb-11 20:22
aeman11-Feb-11 20:22 
AnswerRe: how to change the colour of buttons through timer in c# window application Pin
DaveyM6911-Feb-11 22:11
professionalDaveyM6911-Feb-11 22:11 
GeneralRe: how to change the colour of buttons through timer in c# window application Pin
aeman11-Feb-11 22:34
aeman11-Feb-11 22:34 
GeneralRe: how to change the colour of buttons through timer in c# window application Pin
DaveyM6911-Feb-11 23:04
professionalDaveyM6911-Feb-11 23:04 
GeneralRe: how to change the colour of buttons through timer in c# window application Pin
aeman12-Feb-11 0:08
aeman12-Feb-11 0:08 
GeneralRe: how to change the colour of buttons through timer in c# window application Pin
DaveyM6912-Feb-11 0:20
professionalDaveyM6912-Feb-11 0:20 
GeneralRe: how to change the colour of buttons through timer in c# window application Pin
aeman12-Feb-11 1:02
aeman12-Feb-11 1:02 
GeneralRe: how to change the colour of buttons through timer in c# window application Pin
aeman12-Feb-11 0:06
aeman12-Feb-11 0:06 
Questionhow to insert values in text box at run time in c# and assign it to int Pin
aeman11-Feb-11 19:16
aeman11-Feb-11 19:16 
AnswerRe: how to insert values in text box at run time in c# and assign it to int Pin
OriginalGriff11-Feb-11 20:23
mveOriginalGriff11-Feb-11 20:23 
GeneralRe: how to insert values in text box at run time in c# and assign it to int Pin
aeman11-Feb-11 21:08
aeman11-Feb-11 21:08 
GeneralRe: how to insert values in text box at run time in c# and assign it to int Pin
Anubhava Dimri11-Feb-11 21:19
Anubhava Dimri11-Feb-11 21:19 
GeneralRe: how to insert values in text box at run time in c# and assign it to int Pin
aeman11-Feb-11 21:36
aeman11-Feb-11 21:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.