manually load a rdlc report to reportviewer in vb.net - vb.net

i created a report and trying to load it to a reportviewer manually but not able to get it loaded .
my code
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ReportViewer1.Reset()
Dim ReportDataSource1 As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource
ReportDataSource1.Name = "InvoiceData_DataTable1"
ReportDataSource1.Value = New InvoiceDataTableAdapters.DataTable1TableAdapter().GetData("EBM267")
Me.ReportViewer1.LocalReport.DataSources.Clear()
Me.ReportViewer1.LocalReport.DataSources.Add(ReportDataSource1)
ReportViewer1.LocalReport.ReportEmbeddedResource = "Billmanagement.report.rdlc"
ReportViewer1.RefreshReport()
End Sub
my Dataset name is InvoiceData
DataTable1 has a parameter billno
which i am supplying for demo but not working please let me know why my report is not loading
a blank report with error is comming
"A datasource instance has not been supplied for the datasource DataSet1"

In Billmanagement.report.rdlc you are using an oject with .DataSetName property set as DataSet1: check every Table/List/Matrix in your report.

Related

How to use vb.net dataset, data are from manual added rows and show it to tablix RDLC?

Can you help me? Im having this error when I click the button. It says A data source instance has not been supplied for the Data source 'BatchCodeGenerator'. And I have my Dataset.xsd also added, I dont know if it helps
Private Sub btnPreviewReport_Click(sender As Object, e As EventArgs) Handles btnPreviewReport.Click
Dim DataTable1 As DataTable = New DataTable("DataTable1")
DataTable1.Columns.Add("CardNo", System.Type.GetType("System.String"))
DataTable1.Rows.Add("22-001")
DataTable1.Rows.Add("22-002")
ReportViewer1.LocalReport.ReportPath = System.Environment.CurrentDirectory & "\Reports\BatchBarcodeGenerator.rdlc"
ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("BatchBarcodeGenerator", DataTable1))
Me.ReportViewer1.RefreshReport()
If the error message is correct (BatchCodeGenerator) than you are using a wrong name for your ReportDataSource (BatchBarcodeGenerator).
ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("BatchCodeGenerator", DataTable1))

Calling Crystal Report File

can you help me i have problem with vb.net language.
I want to call crystal report but can't with the data format in gridview sent via crystalreport. with the following code:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim reports As New bpkb_1
reports.SetDataSource(ds.Tables(0))
viewermurabahah.CrystalReportViewer1.ReportSource = reports
viewermurabahah.ShowDialog()
end sub
can you give an example of how the code to call the crystal report file outside of the visual studio vb.net project file?
You can call the load method of the ReportDocument
Dim rpt As New CrystalDecisions.CrystalReports.Engine.ReportDocument
rpt.Load(<Path to your crystal report file>)
rpt.SetDataSource(<your data table>)
YouReportViewer.ReportSource = rpt

VB.NET - System.InvalidCastException (Datagridview)

I get the following error:
System.InvalidCastException: 'Unable to cast object of type 'System.EventArgs' to type 'System.Windows.Forms.DataGridViewCellEventArgs'.'
In this procedure:
Private Sub FillUsersGrid()
Dim sql As String = "SELECT * FROM Users"
Dim dataadapter As New SqlDataAdapter(sql, SQLconn)
Dim Users As New DataSet()
SQLconn.Open()
dataadapter.Fill(Users, "Users_table")
SQLconn.Close()
DgdUsersList.DataSource = Users
DgdUsersList.DataMember = "Users_table"
Me.DgdUsersList.AutoResizeColumns()
End Sub
When I change the following procedure's name:
Private Sub DgdUsersList_SelectionChanged(sender As Object, e As DataGridViewCellEventArgs) Handles DgdUsersList.SelectionChanged
If e.RowIndex >= 0 Then
Row = Me.DgdUsersList.Rows(e.RowIndex)
TxtEmployeesUsername.Text = Row.Cells("Username").Value.ToString
TxtEmployeesPassword.Text = Row.Cells("Password").Value.ToString
CmbEmployeesAccessLevel.Text = Row.Cells("AccessLevel").Value
ChkEmployeesPOSAccess.Checked = Row.Cells("POSAccess").Value
CmbEmployeesPOSPosition.Text = Row.Cells("POSPosition").Value.ToString
End If
DgdUsersList.Rows(CurrentRowIndex).Selected = True
End Sub
From:
Private Sub DgdUsersList_CellClicked(sender As Object, e As DataGridViewCellEventArgs) Handles DgdUsersList.CellClicked
To:
Private Sub DgdUsersList_SelectionChanged(sender As Object, e As DataGridViewCellEventArgs) Handles DgdUsersList.SelectionChanged
The scenario is this; I have two Datagridview controls and I want to make it so that when I click on any cell in DgdEmployeesList, the same row (index) is selected in DgdEmployeesList.
This is because I want to populate a form with a record when a record is clicked, and the employees table in the SQL database is linked to the users one in the same database via a primary key (ID - When an employee profile is created, a user profile is created with the same ID using the same form)
Is there any fix for this (I understand it may be easier to code this just by using the datagridview control itself, but I am unaware of a way to make two tables display inside the control and how to separate them upon saving, along with editing records and deleting them)
Any help is greatly appreciated!
James

How to pass a empty/null parameter to a report

When passing a filter parameter (null and blank checked) to a report in vb.net, I was thinking if the parameter is blank all records would show. It does not. What is the logic behind optional parameters?
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'SkeduleringDatabasisDataSet.Skedulering' table. You can move, or remove it, as needed.
Me.SkeduleringTableAdapter.Fill(Me.SkeduleringDatabasisDataSet.Skedulering)
Dim param1 As New ReportParameter
param1.Name = "ReportParameter1"
param1.Values.Add(Form1.ComboBox1.SelectedValue)
ReportViewer1.LocalReport.ReportPath = "C:\Users\Administrator\Desktop\Trash\WindowsApplication67\WindowsApplication67\Report1.rdlc"
ReportViewer1.LocalReport.SetParameters(New ReportParameter() {param1})
Me.ReportViewer1.RefreshReport()
End Sub
So if I do not make a selection in the combobox (ComboBox1.SelectedIndex = -1) I am expecting the report to show all data?

I am using vb.net and i prepared report using access database. but it doesnot display any data when datasource in start-up path

Public Class SalesReport
Private Sub SalesReport_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'loginDataSet.BillInfo' table. You can move, or remove it, as needed.
Me.BillInfoTableAdapter.Fill(Me.loginDataSet.BillInfo)
Me.ReportViewer1.RefreshReport()
End Sub
End Class
I think you miss some Code you didn't assign and datasource to your report , Try add this line to your code :
Me.ReportViewer1.DataSources.Add(Me.loginDataSet.BillInfo)