Learn how to a build a cloud-first strategyRegister Now


sql database with .net app - how

Posted on 2011-10-12
Medium Priority
Last Modified: 2012-05-12
I'm an asp.net dev
Usually i put a DB in the APP_DATA folder or reference one in SQL server on win server 2008

I'm trying to figure out desktop apps
I need to create an all in one app that ideally doesn't need to be installed (just copy and paste folder)
Is this even possible?

What is the easiest way to create an app with integrated sql server 2008 db?

some instructions on exactly what to do would be helpful
Question by:websss
  • 3
  • 2
  • 2
  • +1
LVL 12

Expert Comment

ID: 36955355
Is there a reason you couldn't use the express edition of sql server and have it installed with your app as a prereq?

Author Comment

ID: 36955382
yeah i want to use express as its free
please bear with me, as i said i'm a asp.net dev, so new to the desktop scene

I'm not sure what you mean about having it installed with my app

Basically, i'm in visual studio 2010 and i need to add a database

each machine the app runs on will be stand alone with no network access
I will also need to do backups of each machine and import the data to my machine every day (manual process somehow)

based on this info, could you explan a bit more of what to do please

Expert Comment

ID: 36955546
As rgn2121 suggested, you can install SQL express on each standalone desktop and do the manual process lateron or try implementing  MSAccess or SQLite (standalone db) as backend.


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

LVL 12

Expert Comment

ID: 36955624
There is a lot of info out there about this, but in its simplest form.  You code against the SQL Express Db and then when you create a setup and deployment project you can select sql express edition as a prereq.

Not sure how you are going to do the backups on remote machines with no network access.  You could create something that you could just go to each workstation and run and it would do the back, then go back to your machine and do the import...
LVL 12

Expert Comment

ID: 36955771
Just as an added note, you can also get Mgmt Studio Express.  I have used this in past development projects...
LVL 40

Accepted Solution

Jacques Bourgeois (James Burger) earned 2000 total points
ID: 36956544
The easiest way to do that is to first install SQL Server Express on all the stations, as stated earlier.

To add a local database to the project, right click on the project name in the Solution Explorer and then: Add...New Item...Data...Local Database.

You will be asked to chose between a DataSet, Data Entity Model or Cancel. This will determine how you will access your database in your code. I suggest that you read about those a bit before deciding. You probably know about those already if you have worked with databases in ASP. Cancel forces you to write straight ADO.NET code. A little more work, but more control and a small gain in performance if done well. DataSet helps you in creating the standard DataSet and DataTable objects that can be used with ADO.NET. The Data Entity Model is a more object oriented view of your data.

There you are, you have a database that is part of the project dans will deploy with it by default.

You will be able to create, modify, test the database through the Server Explorer (View menu or Ctrl-Alt-S). A right-click on the database in the Server Explorer will offer you all the necessary options.

The type of database created this way is very easy to backup. Copy the .sdf file to the backup media as you would do with any other file.


Author Comment

ID: 36960316
Thanks James, that really clearly explains it for me

Just to clarify, i simply copy the SDF file, there is no backup/restore process?
Could i copy the whole directory (with app), and then copy it to a new machine and run it there?

LVL 40
ID: 37622798
If SQL Server Express is installed on the "new machine" and the server has the same name, this should be enough.

If you do a standard install of SQL Server Express on your development computer and all the computers that use the application, the servers will have the same name. This is what Microsoft recommends for SQL Server deployment. But if for some reason you decide to give another name to the server on your development computer, you will ideally give the same name to the servers on all the computers. If the names don't match the one on which you made your development, the connection string that is created by Visual Studio when you create the local database won't work.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month20 days, 23 hours left to enroll

810 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