Click here to Skip to main content
15,896,727 members
Home / Discussions / Database
   

Database

 
AnswerRe: SQL Query Pin
Eddy Vluggen1-Oct-11 8:47
professionalEddy Vluggen1-Oct-11 8:47 
AnswerRe: SQL Query Pin
Niladri_Biswas3-Oct-11 7:14
Niladri_Biswas3-Oct-11 7:14 
AnswerRe: SQL Query Pin
Ganu Sharma5-Oct-11 1:32
Ganu Sharma5-Oct-11 1:32 
AnswerRe: SQL Query Pin
uspatel13-Oct-11 2:48
professionaluspatel13-Oct-11 2:48 
QuestionHOW TO IMPLEMENT MULTIVALUED ATTRIBUTES Pin
robin70029-Sep-11 23:15
robin70029-Sep-11 23:15 
AnswerRe: HOW TO IMPLEMENT MULTIVALUED ATTRIBUTES Pin
Shameel30-Sep-11 0:01
professionalShameel30-Sep-11 0:01 
AnswerRe: HOW TO IMPLEMENT MULTIVALUED ATTRIBUTES Pin
Ganu Sharma5-Oct-11 1:39
Ganu Sharma5-Oct-11 1:39 
QuestionSQL SERVER 2008 Express Backup and Restore using SMO does not effect database Pin
kutbinayi27-Sep-11 5:22
kutbinayi27-Sep-11 5:22 
Hi, in my project I tried to backup my database and then restore using SMO. While backing up and restoring it gives no errors and catches no exception. All of them seem to work great. However, after I perform backup to a file, I deleted the data and/or a table from my database to see whether restoring operation will perform correctly or not. However, when I deleted a table or just data in the table, if I perform restore operation, neither the table nor the data in the table comes back. As a result either backup or restore operation does not work correctly. My backup and restore methods are as in the following :

public bool BackUpDB(string DBpath)
        {
            try
            {
                // Create a new connection to the selected server name
                ServerConnection srvConn = new ServerConnection(Program.serverName);
                // Log in using SQL authentication instead of Windows authentication
                srvConn.LoginSecure = true;
                // Create a new SQL Server object using the connection we created
                srvr = new Server(srvConn);
                // If the user has chosen a path where to save the backup file
                // Create a new backup operation
                Backup bkpDatabase = new Backup();
                // Set the backup type to a database backup
                bkpDatabase.Action = BackupActionType.Database;
                // Set the database that we want to perform a backup on
                bkpDatabase.Database = Program.databaseName;
                //set incremental to false because this is full backup
                bkpDatabase.Incremental = false;
                bkpDatabase.Initialize = true;
                //Specify that the log must be truncated after the backup is complete. 
                bkpDatabase.LogTruncation = BackupTruncateLogType.Truncate;
                // Set the backup device to a file
                BackupDeviceItem bkpDevice = new BackupDeviceItem(DBpath , DeviceType.File);
                // Add the backup device to the backup
                bkpDatabase.Devices.Add(bkpDevice);
                // Perform the backup
                bkpDatabase.SqlBackupAsync(srvr);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }


The following is my restore method :

public bool RestoreDB(string DBpath)
        {
            try
            {
                // Create a new connection to the selected server name
                ServerConnection srvConn = new ServerConnection(Program.serverName);
                // Log in using SQL authentication instead of Windows authentication
                srvConn.LoginSecure = true;
                // Create a new SQL Server object using the connection we created
                srvr = new Server(srvConn);
                // If the user has chosen the file from which he wants the database to be restored
                // Create a new database restore operation
                Restore rstDatabase = new Restore();
                // Set the restore type to a database restore
                rstDatabase.Action = RestoreActionType.Database;                
 
                // If specified database does not exist create it by using master database
                if (!srvr.Databases.Contains(Program.databaseName))
                {
                    try
                    {
                        DbConnection dbcon = new DbConnection("Data Source=" + Program.serverName + ";Initial Catalog=master;Integrated Security=True");
                        dbcon.ExecuteCommand("CREATE DATABASE "+Program.databaseName, null);
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("Veritabanı yaratılırken hata oluştu. Program yine de yedeğinizi geri yüklemeye çalışacak. Ancak bu değişiklik programınıza yansımayabilir. Bu durumda bizimle iletişime geçiniz.","Uyarı",MessageBoxButtons.OK,MessageBoxIcon.Warning);
                    }
                }
                
                // Set the database that we want to perform the restore on
                rstDatabase.Database = Program.databaseName;
                
                rstDatabase.Devices.AddDevice(@DBpath, DeviceType.File);
 
                // If the database already exists, replace it
                rstDatabase.ReplaceDatabase = true;
                // Perform the restore
                rstDatabase.SqlRestoreAsync(srvr);
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }


I searched on this issue a lot and all of the codes seems correct however I could not understand why it does not perform correctly. Anyone can help me on this issue ? Please it is a bit urgent, Thanks...
AnswerRe: SQL SERVER 2008 Express Backup and Restore using SMO does not effect database Pin
Mycroft Holmes27-Sep-11 14:16
professionalMycroft Holmes27-Sep-11 14:16 
QuestionSelect Multi Row, to be Singel Row Pin
Naunt26-Sep-11 20:05
Naunt26-Sep-11 20:05 
AnswerRe: Select Multi Row, to be Singel Row Pin
Mycroft Holmes26-Sep-11 21:28
professionalMycroft Holmes26-Sep-11 21:28 
QuestionRe: Select Multi Row, to be Singel Row Pin
Naunt26-Sep-11 21:45
Naunt26-Sep-11 21:45 
AnswerRe: Select Multi Row, to be Singel Row Pin
Jörgen Andersson27-Sep-11 11:54
professionalJörgen Andersson27-Sep-11 11:54 
GeneralRe: Select Multi Row, to be Singel Row Pin
Naunt27-Sep-11 16:16
Naunt27-Sep-11 16:16 
AnswerRe: Select Multi Row, to be Singel Row Pin
Ganu Sharma5-Oct-11 2:05
Ganu Sharma5-Oct-11 2:05 
GeneralRe: Select Multi Row, to be Singel Row Pin
Naunt5-Oct-11 14:56
Naunt5-Oct-11 14:56 
QuestionData warehous Pin
apadana_198926-Sep-11 9:31
apadana_198926-Sep-11 9:31 
AnswerRe: Data warehous Pin
Mycroft Holmes26-Sep-11 13:09
professionalMycroft Holmes26-Sep-11 13:09 
QuestionDatabase Size Pin
megasoft house25-Sep-11 19:43
megasoft house25-Sep-11 19:43 
AnswerRe: Database Size Pin
loyal ginger26-Sep-11 2:43
loyal ginger26-Sep-11 2:43 
AnswerRe: Database Size Pin
Eddy Vluggen26-Sep-11 12:17
professionalEddy Vluggen26-Sep-11 12:17 
QuestionSQL Servier 2008 Pin
megasoft house25-Sep-11 19:33
megasoft house25-Sep-11 19:33 
AnswerRe: SQL Servier 2008 Pin
Luc Pattyn25-Sep-11 21:49
sitebuilderLuc Pattyn25-Sep-11 21:49 
QuestionDo we need to promote SP's anymore? Pin
Mehdi Gholam24-Sep-11 22:29
Mehdi Gholam24-Sep-11 22:29 
AnswerRe: Do we need to promote SP's anymore? PinPopular
Mycroft Holmes24-Sep-11 23:39
professionalMycroft Holmes24-Sep-11 23:39 

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.