-
No data on report
Hi..
i am trying to make a "RDLC" report but unfortunately no data shows .. so i would like to know what is wrong with my code ..
thank you ..
and here is the code ..
Imports System.Data
Imports System.Data.Sql
Imports System.Data.OleDb
Imports System.Configuration
Imports Microsoft.Reporting.WinForms
Public Class Form1
Dim Con_String As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\Admin\Desktop\Marketing Sheet\Marketing_Sheet\Marketing_Sheet\Data\Marketi ng_Survey.accdb;Persist Security Info=False;" 'Connection string from App.Config
Dim DA As OleDbDataAdapter
Dim DS As New DataSet
Dim Con_Dia As New OleDbConnection(Con_String)
Dim objCmd As New OleDbCommand
Dim rptDataSource As ReportDataSource
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Con_Dia.Open()
If Con_Dia.State = ConnectionState.Open Then
DA = New OleDbDataAdapter("SELECT * FROM Information_Sheet", Con_Dia)
If DA.Fill(DS, "Information_Sheet") > 0 Then
DS.DataSetName = "xxx"
Dim dt As New DataTable
dt = DS.Tables(0)
With Me.ReportViewer1.LocalReport
.ReportPath = "c:\documents and settings\admin\my documents\visual studio 2010\Projects\WindowsApplication2\WindowsApplicati on2\Report1.rdlc"
.DataSources.Clear()
End With
'rptDataSource = New ReportDataSource("luai", DS.Tables("Information_Sheet"))
ReportViewer1.ProcessingMode = ProcessingMode.Local
Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("xxx", DS.Tables("Information_Sheet")))
End If
End If
Con_Dia.Close()
ReportViewer1.RefreshReport()
End Sub
End Class
-
'rptDataSource = New ReportDataSource("luai", DS.Tables("Information_Sheet"))
Did you intend to make this a comment?
-
Yes !! ..
-
Ok, turns out that you can't successfully bind the data source this way. If you bind it at design time using the report viewer smart tags, all this ....
Con_Dia.Open()
If Con_Dia.State = ConnectionState.Open Then
DA = New OleDbDataAdapter("SELECT * FROM Information_Sheet", Con_Dia)
If DA.Fill(DS, "Information_Sheet") > 0 Then
DS.DataSetName = "xxx"
Dim dt As New DataTable
dt = DS.Tables(0)
With Me.ReportViewer1.LocalReport
.ReportPath = "c:\documents and settings\admin\my documents\visual studio 2010\Projects\WindowsApplication2\WindowsApplicati on2\Report1.rdlc"
.DataSources.Clear()
End With
'rptDataSource = New ReportDataSource("luai", DS.Tables("Information_Sheet"))
ReportViewer1.ProcessingMode = ProcessingMode.Local
Me.ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("xxx", DS.Tables("Information_Sheet")))
End If
End If
Con_Dia.Close()
ReportViewer1.RefreshReport()
... can then be replaced with this ...
Me.ReportViewer1.RefreshReport()
-
Ok .. thank you ..
but i do not like to use smart tag .. i would like to pass dataset or datatable through behind code ..
so " do i have to do something before i write this code ??? "
thanks a lot ..
-
I'm afraid that as long as you stay in VB you don't get a choice but to use the smart tags. You can do this in code in ASP but not in VB.
-
thank you man .. !!! i think this is what i was looking for ..
" So .. there is no way but using (smart tags ) "
now .. do i have to use "DataSet1.xsd" ???
-
Er ... why would you not?
-
I did it .. but only with "XSD File "
Thanks for your help ..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks