Attaching a Mdb file created in sql server 2008 in windows form using Visual Studio 2008 professional


  • I have created a Mdb database in sql server 2008 and I have created a windows application using Visual studio 2008. I'm using a appconfig file to connect the Database.

     I have few queries which as follows:

    1. Now how can I attach the mdb file created in sql server 2008 database into my visual studio project so that when I create a setup then the database would be included into it as the other files. My mdb file has procedure and views along with the tables.

    2. What are the prerequisites in order to run the .exe file of the project. I know I have to install .net framework3.0 but in order to run the database what all bare minimum I need to install in order I deploy & executing the setup file and after install it if I run the .exe file in the client's machine

    If possible then please provide me some pictorial images which I would follow and can get my job done.

    Tuesday, December 07, 2010 10:08 PM


All replies

  • To install the database with the Setup application - you need to use the Installer class (Add in your project a class of type Installer) and in the Installer class you need to run the Script of your database (Script containing CREATE DATABASE...CREATE TABLE...CREATE VIEWS...)

    The pre-requisites are .NET Framework (2.0, 3.0/3.5, 4.0) this depends on what version are you using - that's it... If you are using other components you need to take care of them such as reporting tools or other components...



    Ali Hamdar ( -
    Tuesday, December 07, 2010 10:19 PM
  • It would be nice of you if you kindly provide me with a url where there is some demonstration of installer class. I'm using .net framework 3.0 and IDE as VS2008 and SQL SERVER 2008 in my develepor's machine.But I want to create a setup and give it to client.So I need to know what are the prerequisites required in the client's machine in order to run my windows application. I would not share the code. While creating the setup what changes I would make in the appconfig so that I would able to connect the Mdb file.In my developer's environment I connect SQL Server using SQL Server authentication. What is the minimum requirement to run my windows application? I know I have to ask the client to install .net framework 3.0/3.5 but to run the mdb file what all I require? I cannot ask the client to purchase vs.net2008 or sql server2008 as the licensing cost would be a burden for him. Do I have to install the entire SQL Server2008 Express to access the database in the client's machine before I run the setup. I have seen that few projects which are freely downloaded has inbuilt mdb file attached to the project and it runs fine without any problem. I want to create a project like that and then create a setup and give it to my client.
    Wednesday, December 08, 2010 9:44 AM
  • Hi  Uddipto Banerji,


    Welcome to MSDN Forum!


    For deploying a winForm application with a db file question had been solved and given a detail solution in the following thread, you just can reference it.

    how to attach sql database file to creating .exe setup in c#


    Deploying Prerequisites:

    The .net version supports the libraries which the application is using.

    We also need the sql server version supports to read your db file.

    And the others libraries which the application is using.


    We had a special forum for discussing the deployment questions, so if you have more deployment questions, you will need to create thread that forum not this C# forum. There're more deployment experts will give you the expert help.

    ClickOnce and Setup & Deployment Projects


    Please show us a response to let us know if your problem had been solved or if the information provided is helpful on this question.


    Have a nice weekend!

    Mike [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Sunday, December 12, 2010 12:49 PM
  • Duplicate of and

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Thursday, December 16, 2010 2:06 AM