VB.net - How to install it with other files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • emsik1001
    New Member
    • Dec 2007
    • 93

    VB.net - How to install it with other files

    Hi

    I would appreciate if someone could point me in the right direction.

    I'm developing a small application which includes MS Access database in it.


    When someone install it I need to know where the database was installed so I can update the connection string. Currently I use OnceClick VB 2008 feature and it doesn't alow me to specify the folder.

    On Vista PC I have also some issues with the Access database if it is in C drive directly or Program Files folder it becames read-only and I cannot update/insert any records.


    Many thanks in advance.
    Emil
  • lotus18
    Contributor
    • Nov 2007
    • 865

    #2
    Originally posted by emsik1001
    When someone install it I need to know where the database was installed so I can update the connection string. Currently I use OnceClick VB 2008 feature and it doesn't alow me to specify the folder.
    Hi

    The simplest way on how to do it is using Application.Sta rtupPath as your connection path for your access database.

    Something like

    Code:
    Imports System.Data.OleDb
    
    Public conn As System.Data.OleDb.OleDbConnection
    
    Public Sub SetConnection()
    conn=New System.Data.OleDb.OleDbConnection()
            Try
                conn.ConnectionString = ("Provider=Microsoft.Jet.OLEDB.4.0;" & _
                "Data Source=" & Application.StartupPath & "\Database\MyDatabase.mdb;" & _
                "Persist Security Info=False;Jet OLEDB:Database Password=password")
                conn.Open()
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Connection Failed", MessageBoxButtons.OK, MessageBoxIcon.Error)
                conn.Close
    conn.Dispose
            End Try

    Rey Sean

    Comment

    • emsik1001
      New Member
      • Dec 2007
      • 93

      #3
      Thanks that is what I was exactly looking for!!

      Comment

      • emsik1001
        New Member
        • Dec 2007
        • 93

        #4
        Just an update

        I have used this property to get the path but unfortunately my dataset has been using a different path.

        After reading some forums I changed publish status to data file and used this property Application.Use rAppDataPath to get the path and now my updates and dataset are synchronized.

        Regards
        Emil

        Comment

        Working...