sql database with .net app - how

Posted on 2011-10-12
Last Modified: 2012-05-12
I'm an 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
    LVL 12

    Expert Comment

    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

    yeah i want to use express as its free
    please bear with me, as i said i'm a 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
    LVL 3

    Expert Comment

    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.
    LVL 12

    Expert Comment

    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

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

    Accepted Solution

    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

    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

    Expert Comment

    by:Jacques Bourgeois (James Burger)
    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    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…
    Introduction When many people think of the WebBrowser ( control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    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…

    779 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