Question Datasets, Reports, and ReportView

TheCrimsonCoder

New member
Joined
Nov 29, 2010
Messages
1
Programming Experience
Beginner
Howdy Gents and Ladies,

To start, I am using Visual Studio 2005.

I am coding a windows application for a SQL database and would like to add some reports. I have been using and OLEDB connection to query the database and populate the forms, as well as update and insert rows. I was hoping I could apply the same techniques to populating a report, but so far I haven't been successful.

As an example I have a table in the database called "PART_CATEGORY" with the columns "PART_CATEG_ID" and "P_CATEGORY". I proceeded to create a report called Report1.rdlc and with two text boxes and placed the =Field!FieldName expression inside of them. Obviously this won't run without a dataset so I created a new one called DataSet1.xsd and put a single datatable in it called DataTable1 (exciting names, right?), then added two columns called PART_CATEG_ID and P_CATEGORY.

After setting the datasource and placing a ReportViewer to display the report on the form, I run it with this code:

VB.NET:
Imports System.Data.OleDb
Imports System.Data
Imports System.Data.SqlClient
Imports System.Windows.Forms
Imports Microsoft.Reporting.WinForms

Public Class Manufacture
    Private strConnectionString As String = "Provider=SQLOLEDB;Data Source=TheSpearGodROTS;Initial Catalog=StressMC;Integrated Security=SSPI;"
    Private objConnection As OleDbConnection
    Private objCommand As OleDbCommand
    Private objDataAdapter As OleDbDataAdapter
    Private objDataTable As DataTable
    Private dataAdapter As New SqlDataAdapter()





    Private Sub Part_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        GetData()
        Me.ReportViewer1.RefreshReport()
    End Sub
    Private Sub GetData()


        'Initialize the Connection object

        objConnection = New OleDbConnection(strConnectionString)
        objCommand = New OleDbCommand("SELECT P_CATEGORY, P_CATEG_ID FROM PART_CATEGORY ORDER BY P_CATEGORY", objConnection)

        'Initialize the DataAdapter object and set the SelectCommand property
        objDataAdapter = New OleDbDataAdapter
        objDataAdapter.SelectCommand = objCommand

        'Initialize the DataTable object
        objDataTable = New DataTable
        'Populate the DataTable
         objDataAdapter.Fill(objDataTable)
        DataTable1BindingSource.DataSource = objDataTable

I run it and get a ReportView with headers and fields with #Error in them every time. I've been working on this forever and would really like to know what I'm doing wrong. If anyone can provide any insight or links for tutorials I would really appreciate it.

Thanks in advance.
 
Last edited:
Back
Top