How do i restore .bak file in to local mdf and ldf file using c#

Hi,
All,

Please help me,

if i run below qry with local database connection string  "Data Source=(LOCAL)\SQLEXPRESS;Integrated Security=True;AttachDbFilename=G:\MAIN_DB\ XYZ.mdf;User Instance=True" , its not give any error.
but new values are not reflected.

RESTORE FILELISTONLY FROM DISK = 'F:\\DBB\\name.bak'
GO
RESTORE DATABASE XYZ FROM DISK =  'F:\\DBB\\name.bak'

Note:
Database "XYZ" located in G:\MAIN_DB\
>> G:\MAIN_DB\xyz.mdf
>> G:\MAIN_DB\xyz_log.ldf.
developer2966Asked:
Who is Participating?
 
mastooConnect With a Mentor Commented:
Delete the database before the restore so you can be sure you are looking at the one you restored.  If that works then and still shows old data, the backup file must have multiple backups in it and you are restoring the wrong one.  FileList from Sql Server Management Studio will check for this.
0
 
mastooCommented:
You mean you connect with c# and execute that restore from within the c#?  Where are you looking for the new values?  I think you'd use an OpenRecordset to get the results back as a recordset.
0
 
developer2966Author Commented:
>>Where are you looking for the new values?

Old Data only available in Database after Restore Process.
0
All Courses

From novice to tech pro — start learning today.