qadeer37
Well-known member
VB.NET:
Imports db = System.Data
Public Class CustomerADO
Dim cid As Integer
Dim fn, ln, em, pw As String
Dim bl As Decimal
Public CustomerList As New ArrayList()
Private ssConnection As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\QADEER\Documents\MyShop.accdb"
Public Sub GetCustomers()
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
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)
CustomerList.Add(objCustomer)
Loop
End Sub
End Class
Public Class Form1
Private Sub btnImportCustomers_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnImportCustomers.Click
Dim objCustomerADO As CustomerADO
objCustomerADO = New CustomerADO
Dim i As Integer
For i = 0 To objCustomerADO.CustomerList.Count - 1
MessageBox.Show(CType(objCustomerADO.CustomerList.Item(i), String))
Next
End Sub
End Class
Last edited by a moderator: