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?

Re: Trying to restore a .bak in C# by Cor

Cor
Fri Aug 18 12:15:27 CDT 2006

Jayyde,

This is VBNet but without VB extentions on system.net so it should be easy
to use.

http://www.vb-tips.com/dbpages.aspx?ID=ecdc682e-934e-4407-b769-a51330eeb619

Beside that you can forever do a SQL transaction command with
\\\
SQLClient.SQLCommand com("Command",connectionobject);
com.ExecuteNonQuerry();
///

I hope this helps,

Cor

"Jayyde" <anon@hotmail.com> schreef in bericht
news:OnuCWmtwGHA.4968@TK2MSFTNGP03.phx.gbl...
> 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?
>



Re: Trying to restore a .bak in C# by Jayyde

Jayyde
Fri Aug 18 12:48:14 CDT 2006

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.

"Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
news:eWHS6muwGHA.4300@TK2MSFTNGP05.phx.gbl...
> Jayyde,
>
> This is VBNet but without VB extentions on system.net so it should be easy
> to use.
>
> http://www.vb-tips.com/dbpages.aspx?ID=ecdc682e-934e-4407-b769-a51330eeb619
>
> Beside that you can forever do a SQL transaction command with
> \\\
> SQLClient.SQLCommand com("Command",connectionobject);
> com.ExecuteNonQuerry();
> ///
>
> I hope this helps,
>
> Cor
>
> "Jayyde" <anon@hotmail.com> schreef in bericht
> news:OnuCWmtwGHA.4968@TK2MSFTNGP03.phx.gbl...
>> 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?
>>
>
>



Re: Trying to restore a .bak in C# by zacks

zacks
Fri Aug 18 13:45:17 CDT 2006


Jayyde wrote:
> 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.

>
> "Cor Ligthert [MVP]" <notmyfirstname@planet.nl> wrote in message
> news:eWHS6muwGHA.4300@TK2MSFTNGP05.phx.gbl...
> > Jayyde,
> >
> > This is VBNet but without VB extentions on system.net so it should be easy
> > to use.
> >
> > http://www.vb-tips.com/dbpages.aspx?ID=ecdc682e-934e-4407-b769-a51330eeb619
> >
> > Beside that you can forever do a SQL transaction command with
> > \\\
> > SQLClient.SQLCommand com("Command",connectionobject);
> > com.ExecuteNonQuerry();
> > ///
> >
> > I hope this helps,
> >
> > Cor
> >
> > "Jayyde" <anon@hotmail.com> schreef in bericht
> > news:OnuCWmtwGHA.4968@TK2MSFTNGP03.phx.gbl...
> >> 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?
> >>
> >
> >