creating a drill through rdlc report in vb.net in Visual studio 2010 - vb.net

I have a parent and child report that I created in visual studio 2010 using winforms in vb.net. I have setup one text box in the parent report to go to the child report with the respective value as the paramter. However, when I click on the link I get the error:
a data source instance has not been supplied for the data source 'dataset1'
I realize that the dataset1 has to be filled, however I cannot figure out how to fill dataset1. I have researched the topic cand came with the following links:
http://www.developerfusion.com/t/vb.net/
http://msdn.microsoft.com/en-us/library/microsoft.reporting.winforms.reportviewer.drillthrough.aspx
On the winform where the reportviewer controller is located, I have the report drill through handler, but I do not understand how to set the dataset.
I have the following, and I am stuck on how to move on:
Private Sub ReportViewer1_Drillthrough(ByVal sender As System.Object, ByVal e As Microsoft.Reporting.WinForms.DrillthroughEventArgs) Handles ReportViewer1.Drillthrough
Dim localreport = e.Report
Me.Sp_get_testaccountsTableAdapter1.Fill(Me.Retreival.sp_get_testaccounts)
Dim od As New RetreivalTableAdapters.sp_get_testaccountsTableAdapter
End Sub
As you can see, I am filling the table adapter that dataset 1 is supposed to be connected to, but the dataset1 is still not filling... Please help!
Do I need to set a new sqlconnection?? Why do I need to do this? Why can I not just use the sqlconnection string that my tableadapter is using??
Thank you for your help!!

Based upon the example you provided (the second link), the code for accomplishing what you want to do is as follows:
void DemoDrillthroughEventHandler(object sender,
DrillthroughEventArgs e)
{
LocalReport localReport = (LocalReport)e.Report;
localReport.DataSources.Add(new ReportDataSource("Employees",
LoadEmployeesData()));
}
This shows how to assign a new DataSource based upon the drill-through functionality. Just follow the example on the website you gave and you will be fine.
As for why you need to do it, you have to load new data based upon the user drilling into your data.
Your question about filling the table adapter that the dataset is connected to seems a bit confusing. A dataset holds a set of tables. The DataSource for your report uses one table out of a dataset. Therefore, it looks like you might be trying to work backwards (filling a table to fill a dataset).

Related

Adding value to DataGridView column when new record is created

I am using Visual Studio 2017/VB/Winforms and I have a DataGridView which is using a BindingSource to connect to an Access database.
It works well, but I need to programmatically add a value to one of the fields/columns which is hidden from the user when a new record is added. I'm quite sure this is a simple question, but I have been struggling with it for hours trying to figure out which event is the right one to use. Is it a DataGridView event I'm looking for or a BindingSource event?
Here is the code I thought would do the job, but it still gives me an error saying that ProjectID cannot be Null
Private Sub StoresDataGridView_DefaultValuesNeeded(sender As Object, e As DataGridViewRowEventArgs) _
Handles StoresDataGridView.DefaultValuesNeeded
e.Row.Cells("colProjectID").Value = 1
End Sub
Please help me figure this out, as again, I am sure it's something really simple that I'm missing. I also tried setting a break point in that event, and it doesn't even seem to be firing.
I also tried adding this to the form's Load event, and did not get any errors when the form loaded, but when trying to add a new record I still get the same error.
StoresDataGridView.Columns("colProjectID").DefaultCellStyle.NullValue = 1
Use the grid's RowValidating event like this:
StoresDataGridView.Rows(StoresDataGridView.Rows.Count - 1).Cells("colProjectID").Value = 1

RDLC report for multiple checked box items in Listview in vb.net

I need a little help here.
I have a form which shows all the clients, stored in the access database, as a check-box items in a listview control. I want a user to check multiple checkboxes to view details of the selected clients and show it in the rdlc report.
I have written the following codes in VB.net at form_load event, but it only shows the last selected item.
I want some seggustion for the codes which shows details in the rdlc report for all the selected clients.
Private Sub TodaysPendingCompliances_Load(sender As Object, e As EventArgs) Handles MyBase.Load
For Each SelctedCLient As ListViewItem In TodaysCompliances.ListView1.CheckedItems
Me.NoticeComplianceTableAdapter.FillByClientANDComplianceDate(Me.ComplianceDBDataSet.NoticeCompliance, SelctedCLient.Text)
Next
Me.ReportViewer1.RefreshReport()
End Sub
You help will be highly appreciated.
I beleive your problem is that NoticeComplianceTableAdapter.FillByClientANDComplianceDate overwrites the existing data with fresh data from the current iteration every time it is called, so it only holds the last iteration data.
To fix that you will either need to modify that function (or create an overload for it) to not clear the existing data, or create a temporary container that you declare before the loop, and add new data to each time, then attach the report to that temporary data.
Thank you Mr. Bradlet Uffner for you response. You reply helped in finding the solution.
The solution is to set the Clearbeforefill = False for the NoticeComplianceTableAdater
Setting Clearbeforefill to false does not clear the existing data with fresh data from the current iteration.

How to load only newly added record into datagridview?

I am developing the windows application in VS 2010
I am binding the data to grid using generic collection.
Here is the code
Private sub LoadAllCustomer()
Dim oCustomerCollection as new Customers
oCustomers.LoadAll() //Loads all the collection of customers
gvCustomerGrid.DataSource = oCustomerCollection
End sub
Above code work fine...
I have details form which saved the data into customer table in DB. When I save the record , I just want to add new row into grid contains recently added record.
(Previously, I was using Devexpress's grid's RefeshDataSource property.
but now I am using Visual Studio's grid which don't have this property.)
Is there any way for it ? Or I have to load entire data into grid again to show recently added record ?

Report vewier cannot add parameters

I have managed to set a dataset to my tablix on my report viewer that will hold all items belonging to a bill. The issue I present you with is I cannot seem to add any parameters to my textboxes in my .rdlc report. Is this because I have added a connection to my database? Before I added my connection I could easily add parameters, but not anymore. Take a look at my report:
All the red rectangles is where I would usually have my parameters. Is there a way to programmatically do this?
Dim rpJobNum = New ReportParameter("tbJobNo", JobNum)
rv.rvRdlc.LocalReport.SetParameters(rpJobNum)
rv is my report viewer form
rvRdlc is my report viewer control
tbJobNo is my textbox' job number name
JobNum is a variable which holds the respective value (ex: 10000)
If I execute that,I will receive an error:
Any idea why I cannot seem to add any parameter controls? Perhaps there's another way of doing this?
Figured out why I couldn't add parameters. Pretty noob stuff on my part.
Go to View > Report Data
Or... Ctrl + Alt + D
My apologies, but, I'll answer this if it can help someone!
Dim parmlist As New List(Of ReportParameter)()
parmlist.Add(New ReportParameter("tbJobNo ", JobNum))
print.ReportViewer1.LocalReport.SetParameters(parmlist)
you need to create a list, as i did here

Updating a control on another form with the results of a dialog box

I made a windows form which contains a listbox (named VenueList). The listbox is pulling it's values from a list provided by a binding source VenuesBindingSource which is pulling in a ID for the value and a name for the text.
There is a button which is causing a DialogBox to appear which is asking for values to store in the database for a NEW venue. Once the values are filled and insert the database, what's supposed to happen is that the dialog box closes and goes back to the original form which invoked it.
However, instead of updating the list. The list stays the same. But if you close the form and reopen it, you see that a new value was added.
TournamentSettings.VenuesTableAdapter.InsertVenueQuery(Trim(VenueNameTxt.Text), Trim(VenueAddress1Txt.Text), Trim(VenueAddress2Txt.Text), Trim(VenueCityTxt.Text), Trim(VenueProvinceTxt.Text), Trim(VenueZipTxt.Text), Trim(CountryBox.SelectedValue), Trim(VenuePhoneNo.Text), VenueType.SelectedText, VenueWebAddress)
TournamentSettings.VenuesTableAdapter.Fill(TournamentSettings.VenueNameList.Venues)
In the above code, InsertVenueQuery is the name of a query from the designer which is invoked to add the values onto the tableadapter VenuesTableAdapter which is used to fill the combo box on load. I also sent the Fill command to refill the table with the new value.
So the question is, should I go about doing this another way, rather than feeding the Table adapter and sending a fill command on to the datatable? Or is there something that I'm not doing here which I should to force that value into the list. I'm tempted to redo everything outside of the designer but that's a lot of code since I have to essentially run two commands (one to insert the data, and another to get the ##IDENTITY value since this is run on an access database.)
Okay. This one I had to think about for a moment.
Instead of me creating a block of done on the load event, I instead created a sub function called "FillVenueList".
I used the following block of code:
Public Sub FillVenueList()
' Adding values from database to a datatable.
' From there will add to the list box.
Dim VenueConnection As New OleDb.OleDbConnection(DBconnection)
VenueConnection.Open()
Dim VenueConnectionQuery As New OleDb.OleDbCommand("SELECT VenueID, VenueName FROM Venues", VenueConnection)
Dim VenueDataAdapter As New OleDb.OleDbDataAdapter(VenueConnectionQuery)
Dim VenueDataSet As New DataSet
VenueDataAdapter.Fill(VenueDataSet, "Venues")
TrnVenueLst.DataSource = VenueDataSet.Tables("Venues")
TrnVenueLst.DisplayMember = "VenueName"
TrnVenueLst.ValueMember = "VenueID"
VenueConnection.Close()
End Sub
From there I called THIS sub on both the form AND the Add Venue window and I can safely see that this works. SO THAT is how you get a new value onto the form, don't use it as a part of the Load Event but rather call it from the load event block, then call it when you want to add to the list.