I am developing the application using VB.Net and I have to use an MS Access database which is in the another system connected to the LAN. How can I connect to it?
Asked
Active
Viewed 2,929 times
-2
-
and the question is....?? – ɐsɹǝʌ ǝɔıʌ Feb 06 '14 at 11:48
2 Answers
1
With this piece of code you should be able to connect to an Access database and fill a DataAdapter
with the content of a table.
Dim con As New OledbConnection("Provider=microsoft.Jet.oledb.4.0;DataSource=RemoteServerName\Path\mydatabase.mdb;")
Dim cmd As New OledbCommand
Try
con.Open()
cmd.Connection = con
cmd.CommandText = "SELECT * FROM Table"
Dim da As New OleDbDataAdapter(cmd)
da.Fill(ds, Table)
con.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try

ɐsɹǝʌ ǝɔıʌ
- 4,440
- 3
- 35
- 56
-
Thank you sir, in this can i check whether the host is connected or not. that mean i have to show error message when the host is not exist. – S.Manjunathan Feb 06 '14 at 12:06
-
Answer edited as per requested. Using `Try...Catch` you'll try to open the connection. If it fails, a `MessageBox` will appear showing the problem (database not found, max. number of connections reached..or whatever). – ɐsɹǝʌ ǝɔıʌ Feb 06 '14 at 12:10
0
If its a MS Access database, the only way you can share it is to put it in a shared folder and configure the application to use the database from the shared folder. However, please be advised that MSAccess lets only a limited number of users to access at the same time.
-
-
follow link : http://stackoverflow.com/questions/694921/ms-access-mdb-concurrency – pankeel Feb 06 '14 at 12:07