is it possible to do this? i have this simple code that uses datatable to display records in a datagridview and i want to display also the contents of the datatable to a reportviewer.
also can someone suggest me a good read about reportviewer. im having a hard time searching for a good tutorial and most i see uses the wizard thank youCode:Imports System.Data.OleDb Public Class Form1 Dim da As New OleDbDataAdapter Dim cnn As New OleDbConnection Dim bs As New BindingSource Dim oledbCmdBuilder As New OleDbCommandBuilder Dim query As String = "Select * from Table1" Dim cnnString As String = _ "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\house.accdb;" Dim dt As DataTable = New DataTable("Table1") Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click query = "Select * from Table1 WHERE AccountNumber = " & CInt(TextBox1.Text) cnn = New OleDbConnection(cnnString) da.SelectCommand = New OleDbCommand(query, cnn) oledbCmdBuilder = New OleDbCommandBuilder(da) cnn.Open() dt = New DataTable("Table1") da.Fill(dt) cnn.Close() bs.DataSource = dt DataGridView1.DataSource = bs End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load cnn = New OleDbConnection(cnnString) da.SelectCommand = New OleDbCommand(query, cnn) oledbCmdBuilder = New OleDbCommandBuilder(da) cnn.Open() dt = New DataTable("Table1") da.Fill(dt) cnn.Close() bs.DataSource = dt DataGridView1.DataSource = bs Me.ReportViewer1.RefreshReport() End Sub End Class![]()




Reply With Quote
