Imports System.Data.OleDb
Public Class Form3
Public Function ConnectAcc(ByVal command As String) As DataSet
Dim a As New DataSet
a.Tables.Add(0)
Try
Dim conStr As String = "Provider=Microsoft.JET.OLEDB.4.0; Data source=PRBDB.mdb"
Dim Conn As OleDbConnection = New OleDbConnection(conStr)
Dim da As OleDbDataAdapter = New OleDbDataAdapter(command, Conn)
a.Tables.Clear()
da.Fill(a)
Conn.Close()
Catch ex As Exception
MsgBox(ex.Message)
a.Tables.Clear()
a.Tables.Add(0)
Return a
End Try
Return a
End Function
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As DataTable = ConnectAcc("select * from Customer").Tables(0)
PRBDBDataSet2.Customer.Clear()
For i = 0 To dt.Rows.Count - 1
PRBDBDataSet2.Customer.AddCustomerRow(dt.Rows(i).Item(0), dt.Rows(i).Item(1), dt.Rows(i).Item(2))
Next
Me.ReportViewer1.RefreshReport()
End Sub
End Class
Code
For i = 0 To dt.Rows.Count - 1 PRBDBDataSet2.Customer.AddCustomerRow(dt.Rows(i).Item(0), dt.Rows(i).Item(1), dt.Rows(i).Item(2))
Next