[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Creating demo site with database that refreshes every 30 minutes

Posted on 2014-08-29
8
Medium Priority
?
146 Views
Last Modified: 2014-09-02
My client wants me to create a demo site with a demo database that updates every 30 minutes; allowing users to just get in, mess with the data and then auto-reset.

What would I need to do on the server to have it automatically refresh every 30 minutes?

I'm thinking I would create my sample database. Create a backup of it.
Then create a Job that would Restore the backup and run that job every 30 minutes.

Something like this? Will it run if the database is in use? How would that work?
Is there a better way?
RESTORE DATABASE [DEMODBF] FROM  
DISK = N'C:\DBFBackups\DEMODBF_Hourly.bak' 
WITH  FILE = 1,  MOVE N' DEMODBF ' 
TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\DEMODBF.mdf', 
 MOVE N' DEMODBF_log' 
 TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\DEMODBF.ldf', 
  NOUNLOAD,  STATS = 10

Open in new window


Thanks!
0
Comment
Question by:Starr Duskk
8 Comments
 
LVL 14

Expert Comment

by:Brad Groux
ID: 40292979
Utilize scheduled tasks to kick off the process - http://msdn.microsoft.com/en-us/library/windows/desktop/aa383614(v=vs.85).aspx
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 40292991
You could always implement everything apart from the actual update.  Dot net uses disconnected data as the default method anyway.  Then every 30 minutes just trash the in memory data set (user side) and reload it anew.
0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 40293006
Sounds great. Now how do I do that?
0
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!

 
LVL 2

Author Comment

by:Starr Duskk
ID: 40293053
Brad,

I had said:
>>Then create a Job that would Restore the backup and run that job every 30 minutes.

Thanks for the link, but yes, I already know how to create a job and schedule the job. That is built into the job options under Schedule.

thanks!
0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 40293062
I guess I can just test this theory, but wanted to know if anyone knew. Back to my original question, if I create a JOB with a schedule:

>>Will it run if the database is in use?

thanks!
0
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 1900 total points
ID: 40293146
>>Job with schedule - will it run when db in use?

I have not tried to do what you are asking, this is an untested idea.

My understanding of how .net handles databases would be - probably yes apart from occasional times when no it wouldn't.  (Does that help you at all?)

Again I believe that .net would load the data then disconnect.  To update you run code to put data back from the UI by re-opening the connection, performing the update then closing the connection again.  So without any active connection your job would run without problems.  With a read then it may well run properly.  With a write I would anticipate problems.  BUT irrespective of this the UI would not be refreshed until you run code from the front end to do it.  
Hence my idea.  Read the db into dataset/datatables for the UI - just as you would normally.  Repeat this every 30 minutes and refresh the UI.  Just don't write any code to write changes from the UI into the db.
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 100 total points
ID: 40297276
Will it run if the database is in use? How would that work?
No it would not.  You would have to close all connections first.
0
 
LVL 2

Author Closing Comment

by:Starr Duskk
ID: 40299268
thanks!
0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

873 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