Solved

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

Posted on 2013-06-17
2
233 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now