473,320 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

SqlCommand

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
Nov 16 '05 #1
3 1538
Which database is your connection opening?

Simon Smith
simon dot s at ghytred dot com
www.ghytred.com/NewsLook - NNTP Client for Outlook

On 20 Jun 2004 18:04, "Mohammed" wrote:
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



Nov 16 '05 #2
Actually sir I don`t know which database I should open!!
I want to backup a database named TrySql
-----Original Message-----
Which database is your connection opening?

Simon Smith
simon dot s at ghytred dot com
www.ghytred.com/NewsLook - NNTP Client for Outlook

On 20 Jun 2004 18:04, "Mohammed" wrote:
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



.

Nov 16 '05 #3
What connection string are you using for the SqlConnection?
And which line is the error occuring on?

Simon Smith
simon dot s at ghytred dot com
www.ghytred.com/NewsLook - NNTP Client for Outlook

On 20 Jun 2004 19:57, "Mohammed Abdel-Razzak" wrote:
Actually sir I don`t know which database I should open!!
I want to backup a database named TrySql
-----Original Message-----
Which database is your connection opening?

Simon Smith
simon dot s at ghytred dot com
www.ghytred.com/NewsLook - NNTP Client for Outlook

On 20 Jun 2004 18:04, "Mohammed" wrote:
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



.




Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Henrik Dahl | last post by:
Hello! After I've finished using an instance of the SqlCommand class, should I then invoke Dispose() on the instance. I suppose so, as there is a Dispose method, but what does it actually...
1
by: Tom | last post by:
Hello guys Please have a look on following paragraph from ".NET Data Access Architecture Guide". ''''''''''' Although you can repeatedly use the same SqlCommand object to execute the same...
3
by: Jason Huang | last post by:
Hi, In C#.Net, can we have more than one SqlCommand in a SqlConnection? And in one SqlCommand, can we have more than one SqlDataReader in a SqlCommand? In what situation should I use...
0
by: Agnes | last post by:
I got a silly question about Sqlcommand . In my form, there are 5 methods which use the same sqlcommand to execute reader. I had create and dispose for each sqlcommand in every method. Some said...
1
by: job | last post by:
how is it possible to serialize/de-serialize a SqlCommand?
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.