visual c# project .exe and database problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sarabonn
    New Member
    • Nov 2008
    • 69

    visual c# project .exe and database problem

    hallo everyone,

    I have created a project in visual c# and a database with access 2007 .accdb. Now if i want to run the executable file (i mean .exe) in the bin should i also carry the database, if so will it connect to the database automatically or even if the create a DSN and when i run the .exe in the another computer the database connection string will differ. so what can be done ?.. any idea ?... help me please if anyone knows how to do it ..

    Thank you,
    Dinesh.
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    It depends on how you connected to your database in your program...

    Did you use an absolute path? The better way is to use one of the application variables that hold the path information.

    If this is a Forms app, you can get the startup directory by using Application.Sta rtupPath. Or you can get the app data path by using Application.Use rAppDataPath.

    What you should consider doing is adding an installer project to the solution, and adding both the project output and the database file. Have them both installed to the same directory, and use the Application.Sta rtupPath to help build your connection string.

    Comment

    • Ramk
      New Member
      • Nov 2008
      • 61

      #3
      Originally posted by insertAlias
      It depends on how you connected to your database in your program...

      Did you use an absolute path? The better way is to use one of the application variables that hold the path information.

      If this is a Forms app, you can get the startup directory by using Application.Sta rtupPath. Or you can get the app data path by using Application.Use rAppDataPath.

      What you should consider doing is adding an installer project to the solution, and adding both the project output and the database file. Have them both installed to the same directory, and use the Application.Sta rtupPath to help build your connection string.
      You can also use App.config file to hold the connection string information.
      You can define it <Connectionstri ng> entry in it.

      Comment

      • sarabonn
        New Member
        • Nov 2008
        • 69

        #4
        hello insertalias,

        Its a form application, can u tell how can create a installer project ?...

        Thank you.

        Regards,
        Dinesh.
        Originally posted by insertAlias
        It depends on how you connected to your database in your program...

        Did you use an absolute path? The better way is to use one of the application variables that hold the path information.

        If this is a Forms app, you can get the startup directory by using Application.Sta rtupPath. Or you can get the app data path by using Application.Use rAppDataPath.

        What you should consider doing is adding an installer project to the solution, and adding both the project output and the database file. Have them both installed to the same directory, and use the Application.Sta rtupPath to help build your connection string.

        Comment

        • Curtis Rutland
          Recognized Expert Specialist
          • Apr 2008
          • 3264

          #5
          If you are using the full version of Visual Studio (not Express) then one of the project types (under "Other Project Types -> Setup and Deployment") is a Setup Project. Add one of these projects to your current solution. You should be able to find some tutorials on the web on how to use this project type.

          Comment

          • sarabonn
            New Member
            • Nov 2008
            • 69

            #6
            hello insertalias,

            i found how to create a installer project but should i create a application folder installer project and then add the database file to the folder and set the connection string as application.sta rtuppath or application.use rappdatapath to get the database work with the application ?. IS it enough if the add the database file by right clicking the application folder and click add and the click and file and add the database file ?...

            Thank you.

            regards,
            Dinesh.

            Originally posted by insertAlias
            If you are using the full version of Visual Studio (not Express) then one of the project types (under "Other Project Types -> Setup and Deployment") is a Setup Project. Add one of these projects to your current solution. You should be able to find some tutorials on the web on how to use this project type.

            Comment

            Working...