Trying to restore a .bak in C#

  • Thread starter Thread starter Jayyde
  • Start date Start date
J

Jayyde

Can I run a SQL command like:

RESTORE DATABASE NewDB FROM DISK =
'ApplicationStartupPath\SQLSE2005\DevDB.bak' WITH RECOVERY, MOVE
'DevDB_Data' TO 'C:\\Program Files\\Microsoft SQL
Server\\MSSQL.1\\MSSQL\\Data\\NewEB_Data.mdf', MOVE 'DevDB_Log' TO
'C:\\Program Files\\Microsoft SQL
Server\\MSSQL.1\\MSSQL\\Data\\NewDB_Log.ldf'

while connected to the master db installed by default in SQLSE 2005? If not
how the heck do I run this command to restore this db for the client when
they install the app?
 
The SqlCommand was actually exactly what I was using, but it threw and
exception as soon as it tried to do the ExecuteNonQuery line.

Could it have anything to do with the fact that I'm using VS 2003 and trying
to restore into SQL 2005? I don't know the explicit relationship between
the 2 programs well enough to know whether or not you absolutely have to
have VS 2005 to do that or if it doesn't really matter.
 
Jayyde said:
The SqlCommand was actually exactly what I was using, but it threw and
exception as soon as it tried to do the ExecuteNonQuery line.

Could it have anything to do with the fact that I'm using VS 2003 and trying
to restore into SQL 2005? I don't know the explicit relationship between
the 2 programs well enough to know whether or not you absolutely have to
have VS 2005 to do that or if it doesn't really matter.

I don't think there would be any problem using VS2003 and SQL 2005. I
access a SQL2000 server with VS2005 all the time.

I think you would get a better response if you posted the exact
exception that is being thrown.
 
Back
Top