Database back up from mvc.net application - asp.net-mvc

I am using VS2010 and working on mvc application. I want to get Database backup from c# code and then want to restore database.
If some one has solution then please reply.

You can perform database backups using T-SQL script see this MSDN help page:
http://msdn.microsoft.com/en-us/library/ms186865.aspx
Then you could wrap it as a Stored Procedure and execute it from your C# code.

You should think about your question as with two parts. First - Transact SQL script on how to backup and restore database, and second - how to run this script from ASP.Net, simply .NET for general purposes. Both are independent of each other. Answer of 1st question is as Sam adviced, look at MSDN Documentation. For the second sample, you could take a look at SqlCommand, using the first answer with it. For more general purposes, you could take a look at .NET Data Access, but i don't think you will need this one for now

Related

Proper ASP.NET MVC 5 Approach

Looking for some guidance as I am struggling here.
As someone who spent many years developing ASP.NET applications - that has been out of the game for 3-4 years, I am struggling to pick up the latest approaches. Probably as a result of a decade of experience.
My ASP.NET in the past was built using stored procedure calls, and the GUI was built using hand-coded HTML and JavaScript. I used JavaScript to emulate Ajax type functionality (before it was really a well known thing), and also would at times use XSLT to separate presentation from code.
Now, I am trying to move to MVC 5. It's not intuitive to me, and the few popular tutorials out there seem to be doing things that I don't want to do. For example, they are connecting to a simple table through EF, and allowing a user to view, edit or create items.
I'm looking for some basic things:
How do I get data from a stored procedure into some form of a view (GridView, or ListView, etc) - Using a controller, a View, a stored procedure as the data source (using Entity Framework? When i try DB First, and select to include procedures, I can't find them anywhere)
I'm going to want to allow them to override the value in one column. This would be stored down in the database as a different field.
This stuff was always very simple using basic web forms, but I can't find a tutorial that allows me to do anything other than just edit an existing table using EF - which isn't what I want to do. So tempted to just go back to the old fashioned way ...
This is one tutorial that was making sense to me, until it jumped into the code first approach on the database, where it went off the path from what I was looking to do:
http://www.asp.net/mvc/overview/getting-started/introduction/getting-started
Here was another one:
http://www.asp.net/mvc/overview/getting-started/database-first-development/generating-views
But this one was also different than what I was hoping to do.
I wish I wasn't so short on time with this project.
Thanks for any guidance.
You may better wait for ASP.NET 5/vNext/MVC6 release and don't waste your time on MVC5. If your project relies on SQL and works well do not use Entity Framework at all.

How run excel on Azure?

I'm implementing a new application in ASP.NET with MVC4. I'd like to use Azure to host my project.
I've already created a cloud, but I have a problem with my datasheet. I'm using a excel file whom calculates some prices. I tryed to use openXML, but it can't recalculate my sheet, so i can't use it.
Then, I was thinking to install Microsoft Excel on my cloud to run my excel file.
Do you have any different ideas? Could my solution work?
Advice against running Office on a server apply doubly to Azure. The short answer is consistently "Don't do it". I replied to a similar question a couple of years ago, and the answer still applies. (Use a native .NET library)
Personally I would avoid this like the plague.
Unless you're doing a crazy amount of calculations in the Excel sheet, it's likely going to be easier to translate the calculation to an asp list or local sql instance than try to get manipulating Excel via Azure asp working.
If you can give details on what happens in the sheet we can probably help to find a way around the problem.
Edit:
It seems like you may be forced to use Excel, if so the following Microsoft KB article has a long list of problems and possible workarounds for manipulating Excel files server side:
Considerations for server-side Automation of Office

ASP MVC - I need to periodically check my database, how can i do that?

I got an online website written in ASP.MVC. Now, i need to periodically check one table, and if it changes, i need to take further actions related with modifying data in other tables. I could of course write a stand-alone application that would do that for me, but what other options do i have? I am asking, because maybe there is something better which i don't know about.
Assuming that you're using SQL Server, one option would be to add an item to the ASP.NET Cache, and then register a SqlCacheDependency on that item for the table or row that is to be monitored. There is a bit of configuration required to get this up and running, some instructions are here (with the code samples being in VB). When you add the item to the cache that has a SqlCacheDependency, you can specify a callback method that is fired when the data changes, which is how you would update related tables. If you are running SQL Server, want a pre-defined solution provided by Microsoft, and don't mind the setup process and additional database tables and configuration that this includes, this would be a great option.
I got an answer that is satysfying my requirements. There is something called Quartz.net that works just as i wanted it to. :)

Is embedded RavenDB and MVC possible?

i want to use asp MVC with the Embedded RavenDB but it looks like that the DB don't react when debug the MVC application (using VS 2010 and IIS 7.5 Express). For Example in a MVC action i write an object an try to read it from the db in the next step, but the object is not found until the next request. For me it looks like the embedded RavenDB can only listen for request if the MVC application is on idle.
If i changed from embedded to the normal Client/Server it works without problems. I would prefer to use the embedded RavenDB. Maybe someone has some experience with this problem?!
The in memory database takes time to do things, so you might be getting stale results.
The nostalequerieslistener from this question should help: RavenDB how to flush?
I had this issue with unit tests, bascially while RavenDB in memory is fast, the small amount of code between inserting and querying for the object is faster.
You can use RavenDB embedded without any disadvantages, except that your application startup will take a little longer, when you create the EmbeddableDocumentStore, but nothing to worry about.
The only thing that you should keep in mind is that while you can seemlessly switch from embedded to client/server, there are (very few) cases where you can't go the other way without modifying your code. For example, the lazy-features aren't available in the embedded session because just don't make sense there.
Easily you can integrate. this might help.
http://msdn.microsoft.com/en-us/magazine/hh547101.aspx
Please mark as answer if solved your issue.
RavenDB implement the Unit Of Work pattern. Do you call SaveChanges on the document session when you are done?
Yep.
Check this post for a complete sample using best practices:
RavenDB, UnitOfWork and MVC - revisited

.net c# order management library

I have the need for sql based library that will allow me to create products, order items, orders, etc to support e-commerce on a .net mvc site. Does anybody have a suggestion as to where I can purchase a library like this or should I write it myself?
Thanks,
Chris
This might help start you off if you're stuck with getting started with your database schema, it's a library of free database models:
Library of Free Data Models from DatabaseAnswers.org
There's even a sample Orders and Shipping model you could start off with.
I'd then suggest starting off with tool such as SubSonic or Linq to SQL to build your data access widgets:
SubSonic Project
I don't understand why you need a library for this. Since you are not using an open source shopping cart there must be some need for a custom solution. Therefore you should design the tables yourself based on the needs. You can then create Stored Procedures that you call from within your .net code to update the data within the tables. This is pretty trivial and I doubt you need a specific library to accomplish this.

Resources