SqlCommand

M

Mohammed

Dear sirs
How can I use sqlCommand to restore a database???

I`ve written the following code

sqlCommand1.Connection = this.sqlConnection1;
this.sqlConnection1.Open();
sqlCommand1.CommandText = "RESTORE DATABASE trySQL FROM
DISK = 'c:\trySQL_Back.bak'";
int i = sqlCommand1.ExecuteNonQuery();
this.sqlConnection1.Close();

and it gives me the following exception

An unhandled exception of type
'System.Data.SqlClient.SqlException' occurred in
system.data.dll
Additional information: System error.

thanks
Mohammed
 
M

Mohammed Abdel-Razzak

Actually sir I don`t know which database I should open!!
I want to backup a database named TrySql
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top