-1

so I am currently working on a program with an ms access database attached to it. This program is meant to be used by multiple users at the same time, but I want all users be able to save/delete/update records in a single database. I have searched for it online but really couldn't find anything. Please help :(

I am using vb.net 2008 and MS Access 2013

nothere
  • 5
  • 1
  • 6
  • 1
    Read this first: https://stackoverflow.com/questions/1672077/setting-up-an-ms-access-db-for-multi-user-access. You can put MDB/ACCDB on a shared resource across the network and your app handles incoming request from users. – Tetsuya Yamamoto Jun 12 '17 at 03:44
  • If I put my MDB file on a shared drive, then will I have to change all the codes linking several forms to the MDB file or maybe just the connection string? – nothere Jun 12 '17 at 04:03
  • Measure twice, cut once. Please read [ask] and take the [tour] – Ňɏssa Pøngjǣrdenlarp Jun 12 '17 at 13:08

1 Answers1

0

Create an application setting of type string with user scope. Then capture the database location via an OpenFileDialog and save the path in the setting.

To Save the Setting:

If Open_File_Dialog_Set_Database.ShowDialog(Me) = Windows.Forms.DialogResult.OK Then

        My.Settings.dbpath = Open_File_Dialog_Set_Database.FileName

        My.Settings.Save()

        MessageBox.Show("Database path has been saved as " & My.Settings.dbpath, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information)

Else

    ....


End If

Once captured use as follows:

Using con As New OleDb.OleDbConnection
        con.ConnectionString = "Provider = Microsoft.ACE.OLEDB.12.0;" & _
                               "Data Source = " & My.Settings.dbpath
        con.Open()

        .....

        con.Close()

End Using

Keep in mind that the database must be shared where you have read/write permissions if you want to make changes to the database.