invalid column name RDLC Report Viewer says while populating data to data source using multiple data sources - vb.net

I am trying to print an RDLC report that gets data from multiple data sources. The first data source is filled with data while the other data source gives the following error
"Invalid Column Name 'INV123'"
The code for filling the data sources is as follows:
frmInvoiceReport.DataTable_InvoiceTableAdapter.Fill(frmInvoiceReport.SIS_DBDataSet.DataTable_Invoice)
frmInvoiceReport.DataTable_InvoiceInfoTableAdapter1.Fill(frmInvoiceReport.SIS_DBDataSet.DataTable_InvoiceInfo)
'The DataSet created.
Dim myConnection As SqlConnection = New SqlConnection(cs)
Dim myDA As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM [View_Invoice_Details] Where InvID = " & txtID.Text, myConnection)
Dim myDS As New DataSet
myDA.Fill(myDS, "DataTable_Invoice")
Dim myDa2 As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM [View_InvoiceInfo] Where InvoiceNo = " & txtInvoiceNo.Text, myConnection)
Dim myDs2 As New DataSet
myDa2.Fill(myDs2, "DataTable_InvoiceInfo")
frmInvoiceReport.ReportViewer1.LocalReport.DataSources.Clear()
Dim DtSrc As ReportDataSource = New ReportDataSource("SIS_DBDataSet", myDS.Tables("DataTable_Invoice"))
Dim DtSrc2 As ReportDataSource = New ReportDataSource("SIS_DBDataSet", myDs2.Tables("DataTable_InvoiceInfo"))
frmInvoiceReport.ReportViewer1.LocalReport.DataSources.Add(DtSrc)
frmInvoiceReport.ReportViewer1.LocalReport.DataSources.Add(DtSrc2)
frmInvoiceReport.ReportViewer1.RefreshReport()
frmInvoiceReport.ShowDialog()
I am not sure where the error arises. I have debugged the code and it catches an exception saying that the column name is invalid. I need a quick fix for that.

Related

Visual Basic - No value given for one or more required parameters

I have a DataGridView which displays the contents of a table (with sql query). But whenever I run the code, it displays this error:
No value given for one or more required parameters.
Where did it went wrong? The program ran without displaying any errors.
Here's the code for displaying in the DataGridView:
Dim connString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\BSPDatabase.accdb"
MyConn = New OleDbConnection
MyConn.ConnectionString = connString
ds = New DataSet
tables = ds.Tables
da = New OleDbDataAdapter("Select * from [Transactions] where transMonth=" & monthCombobox.Text & "", MyConn)
da.Fill(ds, "BSPDatabase") 'Change items to your database name
Dim view As New DataView(tables(0))
source1.DataSource = view
TransactionsDataGridView.DataSource = view
I think you are forming bad SQL. The value needs to be in quotes.
da = New OleDbDataAdapter(String.Format("Select * from [Transactions] where transMonth ='{0}'", monthCombobox.text), MyConn)

Changing an existing datagridview column

I want to change a datagridview column 'TeamAssignment' which loads from the database to have dropdowns (which is also populated from the database)
Dim conn As New SqlConnection(My.Resources.FCLRptConn)
Dim cmd As New SqlCommand("spFCLLUVTeamAssignment", conn)
Dim da As New SqlDataAdapter(cmd)
Dim TeamAssign As New DataSet
da.Fill(TeamAssign)
teamComBo.HeaderText = "Team Assignment"
teamComBo.DataPropertyName = "TeamAssignment"
teamComBo.DataSource = TeamAssign.Tables(0)
teamComBo.DisplayMember = "FCLTeamName"
teamComBo.ValueMember = "FCLTeamID"
dgvAgentAssignment.Columns.RemoveAt(5)
dgvAgentAssignment.Columns.Insert(5, teamComBo)
This is what I have used but I get an error that says that a column exists. How would I keep my existing column without having to remove it but populate it with the dropdowns?
Thanks

VB - Value cannot be null error

The problem I am having is as follows:
I am using an SQL query to take data out of a table like so:
Dim query As String = "SELECT Pronunciation, Character FROM [Hiragana List] WHERE Pronunciation='" & pronunciation & "';"
Dim instruction = New SqlCommand(query, sqlCon)
Dim da As New SqlDataAdapter
da.SelectCommand = instruction
da.Fill(HiraganaList)
This should then take the data from the table and fill-in a datatable called "Hiragana List", however when the code reaches the line
da.Fill(Hiragana List)
The operation of the program stops and it instead returns this error:
An unhandled exception of type 'System.ArgumentNullException' occurred in System.Data.dll
Additional information: Value cannot be null.
I took a look at the "Hiragana List" table itself and changed it so that it would accept Nulls in each of the field in order to see if it would fix it, unfortunately it still returns the same error.
(edit) Here is the declaration for the datatable 'Hiragana List':
Dim connectionString As String = "Server=my_server;Database=name_of_db;User Id=user_name;Password=my_password"
Dim sqlCon = New SqlConnection("Data Source=(LocalDB)\v11.0;AttachDbFilename='J:\Computing Coursework\real project\KES\KES\Kana List.mdf';Integrated Security=True;Connect Timeout=30")
Dim HiraganaList As DataTable
Dim KanjiList As DataTable
Dim Katakana As DataTable
Dim YoonList As DataTable
Dim YoonKataList As DataTable
Ok on your code befor da.Fill(HiraganaList) add this Code :
HiraganaList = New DataTable
you Need this to avoid null Exception.

clear all records from data set in vb.net

i am working on vb.net windows form..in my button click i have given code like this:
Dim rpt As New DelivaryPerformance
Dim ds As New DataSet
Dim da As New SqlDataAdapter
Dim rpt As New DelParkingtype
Dim locid As Integer = RecordID("Locid", "Location_tbl", "LocName", CmbLocations.Text)
Dim cmdstatus As New SqlCommand("IBS_DelivaryStaus", con.connect)
cmdstatus.CommandType = CommandType.StoredProcedure
cmdstatus.Parameters.Add("#locid", SqlDbType.Int).Value = locid
da.SelectCommand = cmdstatus
da.Fill(ds)
If (ds.Tables(0).Rows.Count > 0) Then
rpt.SetDataSource(ds.Tables(0))
' CrystalReportViewer1.ReportSource = rpt
End If
while i am clicking each time in my button click,,i want to clear all records from my data set,,how i can clear my all records from my dataset
If you want to clear all rows from the tables contained in a dataset you could use
ds.Clear()
MSDN reference
DataSet.Clear
This however, removes the records, not the tables schema. If you want to get rid of the tables also then you need to use
ds.Tables.Clear()
However, in the context of your code, the dataset is created as new, and so it is already empty until you fill it with the appropriate command, so it is not clear in which context you need to empty it.

How to redirect one selected item on data gridview to another data gridview in vb.net?

I'm using vb.net. I have successfully query out this in data gridview by using sql
After I click the "Performance", I want to query out the details of "LM3409QHVMYUY8" and the details is inside the oracle and display into another data grid view
How I'm going to that ?
Thanks
I'm used this code to get the above datagridview:
Dim connectionString As String = System.Configuration.ConfigurationManager.AppSettings("connCommon")
Dim sqlConnection As SqlClient.SqlConnection = New SqlClient.SqlConnection(connectionString)
Dim queryString As String = "SELECT * FROM ODS_Nspn_Pkg_Group_v WHERE ([SAG-Grp] = '" & ddlPackage & "')"
Dim sqlCommand As SqlClient.SqlCommand = New SqlClient.SqlCommand(queryString, sqlConnection)
sqlCommand.CommandTimeout = 0
Dim dataAdapter As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(sqlCommand)
Dim dataSet As DataSet = New DataSet
dataAdapter.Fill(dataSet)
Return dataSet