Reputation: 2289
I am completely lost here and I am running out of time. Let me explain my situation:
I have created a software in C# express 2010 and SQL Server Express 2008 R2.
Now in the settings section of my software, the user is supposed to be able to make manual back ups/restores of the database.
Also he is supposed to be able to schedule back ups of the database, which will run at time that he will set.
I do not have a clue on how to get both of these working and I am hoping that someone here may point me in the correct direction.
Please keep in mind that when the user will install the software on his computer, he will not have sql server installed (I am saying this because I am under the impression that SMO requires sql server to be pre installed on the client machine).
Thank you
Upvotes: 0
Views: 3169
Reputation: 1428
You could look at this C# example for using SMO to backup the database
The other option is to run a process and call sqlcmd from code
http://www.sqldbatips.com/showarticle.asp?ID=27
Here is some sample code to execute process
string fileName = @"C:\Backup.sql";
ProcessStartInfo info = new ProcessStartInfo("sqlcmd", @" -S .\SQLExpress -U sa -d mydatabasename -o C:\sqlout.txt -i """ + @fileName + @""" -P");
info.UseShellExecute = false;
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
info.RedirectStandardOutput = true;
Process p = new Process();
p.StartInfo = info;
p.Start();
Upvotes: 0
Reputation: 56769
You could always try Google.
I'm assuming you can create Windows Forms and wire up OnClick
events, and run SqlCommand
's against the database. Then it's just a matter of using the documentation above to write the appropriate queries when the user presses the appropriate button.
BTW: This is a Q&A site, not an emergency consultant shop. Don't say things like "I'm running out of time" and don't write up large lists of requirements and say tell me how to do this. You'll get absolutely no help that way. Ask specific questions after demonstrating your effort and specific technical problem.
Upvotes: 1