Solved

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

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 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

11 Experts available now in Live!

Get 1:1 Help Now