qadeer37
Well-known member
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?
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?