Click here to Skip to main content
15,900,108 members
Home / Discussions / Database
   

Database

 
QuestionReport Definition is not valid. [modified] Pin
gmhanna16-Sep-10 16:25
gmhanna16-Sep-10 16:25 
Questionunable to Access complete database features Pin
sanjaypujari16-Sep-10 6:26
sanjaypujari16-Sep-10 6:26 
AnswerRe: unable to Access complete database features Pin
Pete O'Hanlon16-Sep-10 8:08
mvePete O'Hanlon16-Sep-10 8:08 
QuestionSET XACT_ABORT ON Pin
eraser95015-Sep-10 21:03
eraser95015-Sep-10 21:03 
AnswerRe: SET XACT_ABORT ON Pin
Mycroft Holmes15-Sep-10 23:03
professionalMycroft Holmes15-Sep-10 23:03 
AnswerRe: SET XACT_ABORT ON Pin
Pete O'Hanlon16-Sep-10 8:07
mvePete O'Hanlon16-Sep-10 8:07 
GeneralRe: SET XACT_ABORT ON Pin
eraser95019-Sep-10 21:23
eraser95019-Sep-10 21:23 
QuestionProblem in restoring SQL Server MDF File database Pin
kirankkk200915-Sep-10 20:06
kirankkk200915-Sep-10 20:06 
Here is code
<br />
SqlConnection connection =  new SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename="D:\Working Directory\Win Application\Nakoda\Development\Bin\Database\cERP.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True");<br />
<br />
 ServerConnection srvConn = new ServerConnection(connection);<br />
                // Create a new SQL Server object using the connection we created<br />
                srvSql = new Server(srvConn);<br />
<br />
                // If the user has chosen the file from which he wants the database to be restored<br />
                if (openBackupDialog.ShowDialog() == DialogResult.OK)<br />
                {<br />
                    //Declare a BackupDeviceItem by supplying the backup device file name in the constructor, and the type of device is a file.<br />
                    BackupDeviceItem bdi = default(BackupDeviceItem);<br />
                    bdi = new BackupDeviceItem(openBackupDialog.FileName, DeviceType.File);<br />
<br />
                    //Create another file device for the differential backup and add the Backup object.<br />
                    BackupDeviceItem bdid = default(BackupDeviceItem);<br />
                    bdid = new BackupDeviceItem(openBackupDialog.FileName, DeviceType.File);<br />
<br />
                    // Set the database that we want to perform the restore on<br />
                    string db = cmbDatabase.SelectedItem.ToString();<br />
                    //rstDatabase.Database = db;<br />
<br />
                    //Define a Restore object variable.<br />
                    Restore rs = default(Restore);<br />
                    rs = new Restore();<br />
                    //Set the NoRecovery property to true, so the transactions are not recovered.<br />
                    rs.NoRecovery = true;<br />
                    //Add the device that contains the full database backup to the Restore object.<br />
                    rs.Devices.Add(bdi);<br />
                    //Specify the database name.<br />
                    rs.Database = db;<br />
                    //Restore the full database backup with no recovery.<br />
                    rs.SqlRestore(srvSql);<br />
<br />
<br />


I Got Exception

Microsoft.SqlServer.Management.Smo.FailedOperationException occurred
HelpLink=http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.50.1447.4+((KJ_RTM).100213-0103+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Restore+Server&LinkId=20476
Message=Restore failed for Server '\\.\pipe\1FF7F0B1-18D8-42\tsql\query'.
Source=Microsoft.SqlServer.SmoExtended
Operation=Restore
StackTrace:
at Microsoft.SqlServer.Management.Smo.Restore.SqlRestore(Server srv)
at DatabaseBackup.SQL_Backup_Restore.btnRestore_Click(Object sender, EventArgs e) in D:\Working Directory\Win Application\Nakoda\Development\Source\DatabaseBackup\MSSQLBackupRestore.cs:line 186
InnerException: Microsoft.SqlServer.Management.Common.ExecutionFailureException
Message=An exception occurred while executing a Transact-SQL statement or batch.
Source=Microsoft.SqlServer.ConnectionInfo
StackTrace:
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType)
at Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(StringCollection queries)
at Microsoft.SqlServer.Management.Smo.BackupRestoreBase.ExecuteSql(Server server, StringCollection queries)
at Microsoft.SqlServer.Management.Smo.Restore.SqlRestore(Server srv)
InnerException: System.Data.SqlClient.SqlException
Message=RESTORE cannot process database 'D:\WORKING DIRECTORY\WIN APPLICATION\NAKODA\DEVELOPMENT\BIN\DATABASE\CERP.MDF' because it is in use by this session. It is recommended that the master database be used when performing this operation.
RESTORE DATABASE is terminating abnormally.
Source=.Net SqlClient Data Provider
ErrorCode=-2146232060
Class=16
LineNumber=1
Number=3102
Procedure=""
Server=\\.\pipe\1FF7F0B1-18D8-42\tsql\query
State=1
StackTrace:
at Microsoft.SqlServer.Management.Common.ConnectionManager.ExecuteTSql(ExecuteTSqlAction action, Object execObject, DataSet fillDataSet, Boolean catchException)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
InnerException:
AnswerRe: Problem in restoring SQL Server MDF File database Pin
Mycroft Holmes15-Sep-10 22:59
professionalMycroft Holmes15-Sep-10 22:59 
QuestionIs this unique ID generation procedure correct ? Pin
virang_2115-Sep-10 19:11
virang_2115-Sep-10 19:11 
AnswerRe: Is this unique ID generation procedure correct ? Pin
Mycroft Holmes15-Sep-10 19:55
professionalMycroft Holmes15-Sep-10 19:55 
AnswerRe: Is this unique ID generation procedure correct ? Pin
David Skelly15-Sep-10 22:52
David Skelly15-Sep-10 22:52 
QuestionT-SQL 2005 Inner join data from a view to the resultset of a stored procedure. Pin
Steven J Jowett13-Sep-10 5:54
Steven J Jowett13-Sep-10 5:54 
AnswerRe: T-SQL 2005 Inner join data from a view to the resultset of a stored procedure. Pin
Stryder_113-Sep-10 8:00
Stryder_113-Sep-10 8:00 
AnswerRe: T-SQL 2005 Inner join data from a view to the resultset of a stored procedure. Pin
David Mujica13-Sep-10 8:06
David Mujica13-Sep-10 8:06 
GeneralRe: T-SQL 2005 Inner join data from a view to the resultset of a stored procedure. Pin
Steven J Jowett13-Sep-10 12:08
Steven J Jowett13-Sep-10 12:08 
AnswerRe: T-SQL 2005 Inner join data from a view to the resultset of a stored procedure. Pin
Mycroft Holmes13-Sep-10 12:34
professionalMycroft Holmes13-Sep-10 12:34 
AnswerRe: T-SQL 2005 Inner join data from a view to the resultset of a stored procedure. Pin
PIEBALDconsult13-Sep-10 17:01
mvePIEBALDconsult13-Sep-10 17:01 
QuestionDB architecture Pin
adilsardar13-Sep-10 2:46
adilsardar13-Sep-10 2:46 
AnswerRe: DB architecture Pin
R. Giskard Reventlov13-Sep-10 3:38
R. Giskard Reventlov13-Sep-10 3:38 
AnswerCentralized DB Pin
David Mujica13-Sep-10 4:13
David Mujica13-Sep-10 4:13 
GeneralRe: Centralized DB Pin
adilsardar14-Sep-10 0:03
adilsardar14-Sep-10 0:03 
AnswerRe: DB architecture Pin
Luc Pattyn13-Sep-10 4:32
sitebuilderLuc Pattyn13-Sep-10 4:32 
AnswerRe: DB architecture Pin
Eddy Vluggen13-Sep-10 10:11
professionalEddy Vluggen13-Sep-10 10:11 
GeneralRe: DB architecture Pin
adilsardar14-Sep-10 0:06
adilsardar14-Sep-10 0:06 

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.