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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
mastooCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.