Click here to Skip to main content
16,019,018 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have developed a form in vb.net to dispaly a report by getting the data from databse using a select query. But the report doesn't show any value but shows some error.
The code is as below

VB
Dim sqlcon As SqlCeConnection, sqlcmd As SqlCeCommand, adp As SqlCeDataAdapter, ds As New DataSet
        Dim cmdstr As String
        Dim s_ds As New sales_bill_dataset
        Dim t As New DataTable("sale_details")
        Dim r As DataRow
        Try



            sqlcon = New SqlCeConnection(My.Settings.connectionstr_val)
            sqlcon.Open()
            cmdstr = "SELECT sales.order_id, sales.order_date, sales.cust_name, sales.cust_add, sales.cust_phone, sales.total_bill, sales.tax_amt, sales.tax_val, sales.discount_amt, " & _
                " sales.disc_val, sales.gross_total, sales.ref, sales_details.order_id AS Expr1, sales_details.prod_id, sales_details.prod_s_price, sales_details.qty, " & _
                " sales_details.total_bill AS Expr2, sales_details.disc_amt, sales_details.disc_val AS Expr3, sales_details.tax_amt AS Expr4, sales_details.tax_val AS Expr5, " & _
                " sales_details.gross_bill, sales_payment_details.order_id AS Expr6, sales_payment_details.payment_date, sales_payment_details.payment_amt, " & _
                " sales_payment_details.payment_option, sales_payment_details.cheque_no, sales_payment_details.dd_no, stock.prod_id AS Expr7, stock.prod_name, " & _
                " stock.prod_comp_name, stock.prod_spec, stock.prod_ref, stock.warranty_period, stock.prod_p_price, stock.prod_s_price AS Expr8, stock.qty_stock" & _
                " FROM sales INNER JOIN" & _
                "  sales_details ON sales.order_id = sales_details.order_id INNER JOIN" & _
                "  sales_payment_details ON sales.order_id = sales_payment_details.order_id INNER JOIN" & _
                "  stock ON sales_details.prod_id = stock.prod_id" & _
                " WHERE sales.order_id = 2" '&  & "'"
            sqlcmd = New SqlCeCommand(cmdstr, sqlcon)
            adp = New SqlCeDataAdapter
            adp.SelectCommand = sqlcmd
            adp.Fill(ds)
            t = s_ds.Tables(0)
            For i = 0 To ds.Tables(0).Rows.Count - 1
                r = t.NewRow
                r(0) = ds.Tables(0).Rows(i).Item(0)
                r(1) = FormatDateTime(ds.Tables(0).Rows(i).Item(1), DateFormat.GeneralDate)
                For j = 2 To ds.Tables(0).Columns.Count - 1
                    r(j) = ds.Tables(0).Rows(i).Item(j)
                Next
                t.Rows.Add(r)
            Next

            Dim rds As New Microsoft.Reporting.WinForms.ReportDataSource
            rds.Name = "Dataset1"
            MsgBox(Me.sales_bill_dataset.DataTable1.Rows.Count)
            rds.Value = t
            With ReportViewer1
                .Reset()
                .LocalReport.DataSources.Clear()
                '.LocalReport.ReportEmbeddedResource = "aeon.sales_bill.rdlc"
                .LocalReport.ReportPath = "D:\Vb .net Projects\aeon\aeon\sales_bill.rdlc"
                .LocalReport.DataSources.Add(rds)
                .LocalReport.Refresh()
            End With
            ReportViewer1.RefreshReport()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        Me.DataTable1TableAdapter.Adapter.SelectCommand = sqlcmd
        DataTable1TableAdapter.Fill(sales_bill_dataset.DataTable1)
        ReportViewer1.RefreshReport()

It will create an error as below
an error occured during local report processing.<br />
An error has occured during report processing dataset1
Posted

1 solution

Hi,

Did you check your connection settings in your rdlc report ?
Go to Report Data and check your connection settings. See that your data source is correct and your username and password are right.

Also run your query from query designer and check that data is correctly returned.

Regards,
Praneet Nadkar
 
Share this answer
 
Comments
SITU.PATI 16-Oct-14 6:35am    
everything is right sir, the data is extracing, it is passing to rds(the datasource for report viewer) but the same error is generating.
[no name] 16-Oct-14 6:50am    
Try assigning the name and value of the dataset

Dim rds As New ReportDataSource()
rds.Name = "DataSet1"
'this is the name of the DataSet on your report rdlc
rds.Value = datatable
'this contains the data and columns referenced in the dataset
ReportViewer1.LocalReport.DataSources.Add(rds)
SITU.PATI 25-Oct-14 11:15am    
I have already assigned, But still no work.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900