?
Solved

Create a service to backup a sql database in Visual Studio 2008

Posted on 2013-06-17
2
Medium Priority
?
241 Views
Last Modified: 2013-06-18
Hi Experts

I am new to Visual Studio and would like to create a service that calls a stored procedure that backs up a SQL database that runs in SQL Express.  The service needs to run every morning. I would like call the ADO parameters from a config file.
Can someone point me in the right direction please

Many thanks
Alan
0
Comment
Question by:caandal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 23

Accepted Solution

by:
Ioannis Paraskevopoulos earned 2000 total points
ID: 39255577
Hi,

You have two choices, either create a service that will internally check the time in a specified interval, or create a console application that will be called from the Windows Task Scheduler.

Now, as far as the parameters are concerned, you may do the following:
1.Open VS 2008
2.Create a New Project
3.In the Menu go to "Project" and select "YourProjectName Properties"
4.In the opened window go to Settings Tab on the left

You will see a grid with "Name","Type","Scope" and "Value" columns.

"Name" is the name by which you may refer to the specified setting
"Type" is the type of the setting such as integer or string for basic types, or you may even have a specific enumeration
"Scope" from msdn:
Application-scoped settings can be used for information such as a URL for a Web service or a database connection string. These values are associated with the application. Therefore, users cannot change them at run time.

User-scoped settings can be used for information such as persisting the last position of a form or a font preference. Users can change these values at run time.
"Value" is the actual value of the setting.

Now, let's assume that you have a stored procedure that gets the DBName, and the full file name of the backup as arguments.

For this you will need at least three settings in your project:
1.ConnectionString
Name:MyConnString
Type:ConnectionString
Scope:Application
Value: Run the wizard and create the connection string applicable to your scenario

2.DBName
Name:DBName
Type:String
Scope:Application
Value:Your DataBase name you wish to backup

3.Backup Target Path
Name:BackupTarget
Type:String
Scope:Application
Value:The path you wish to save your backup

You may refer to these parameters from your code like:
My.Settings.SettingName

Open in new window


For instance if you would like to get the connection string you would call it as:
My.Settings.MyConnString

Open in new window


For reference in C# you would call it as:
Properties.Settings.Default.MyConnString

Open in new window


That is for starters...Post if you need any more clarification...

Giannis
0
 

Author Closing Comment

by:caandal
ID: 39256108
Hi Giannis

Thanks for that - it does not look too daunting

Cheers
Alan
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question