How to access file on another pc?

qadeer37

Well-known member
Joined
May 1, 2010
Messages
63
Location
Hyderabad,pakistan
Programming Experience
1-3
Public Sub GetCustomers()


Dim ssConnection As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=d:\Documents\MyShop.accdb"

Dim dbConn As db.OleDb.OleDbConnection
dbConn = New db.OleDb.OleDbConnection(ssConnection)

dbConn.Open()

Dim sql As String = "Select * from Customer;"

Dim dbCmd As db.OleDb.OleDbCommand
dbCmd = New db.OleDb.OleDbCommand(sql, dbConn)


Dim DataReader As db.OleDb.OleDbDataReader
DataReader = dbCmd.ExecuteReader


listCustomer = New List(Of Customer)

Do While DataReader.Read()


CID = System.Convert.ToInt32(DataReader("CID"))
FN = System.Convert.ToString(DataReader("FirstName"))
LN = System.Convert.ToString(DataReader("LastName"))
EM = System.Convert.ToString(DataReader("EmailAddress"))
BL = System.Convert.ToDecimal(DataReader("Balance"))
PW = System.Convert.ToString(DataReader("Password"))

Dim objCustomer As Customer
objCustomer = New Customer(CID, FN, LN, EM, BL, PW)

listCustomer.Add(objCustomer)

Loop

dbConn.Close()

End Sub

to retrieve these records from a client pc do I need to just change the connection string or I have to import a namespace and then use those objects to connect?
:confused:
 
Hello. Please put your code in [ CODE ] [ / CODE ] tags! Change the source, like as follows:

VB.NET:
Dim ssConnection As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=[B]\\ANOTHERPC\NetworkShare\MyShop.accdb[/B]"

Note: the folder in which MyShop.accdb is located must be a shared directory on the network.
 
Last edited:
You can also set a shared folder (map a drive letter) on the local machine, so that any attempt to access D:
will conenct to the other drive:

WARNING: I have in the past had massive, massive problems with Access databases and network shares. Deadlocks happened so often that the client rejected the app. Access is NOT a proper network database. Use SQL server or oracle instead, both of which exist in free versions supported by Visual Studio
 
Back
Top