Solved

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

Posted on 2013-06-17
2
236 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
2 Comments
 
LVL 23

Accepted Solution

by:
Ioannis Paraskevopoulos earned 500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 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