我使用此代码从数据库中获取数据。在其他条件下,如If ProductCombo.Text =" All"这段代码完美无缺。但在这种情况下,它会给出'System.InvalidOperationException' occurred in System.Data.DataSetExtensions.dll
异常。我无法理解它是什么。请帮忙。
If ProductCombo.Text = "All" Then
If CheckDate.Checked = True Then
Dim salesTbl As DataTable = SilexDatabaseDataSet.Tables("Sales")
Dim query = _
From sale In salesTbl.AsEnumerable() _
Where sale.Field(Of DateTime)("Date") >= DateTimePicker1.Value _
Select sale
Try
Dim boundTable As DataTable = query.CopyToDataTable()
FilterGrid.DataSource = boundTable
Catch ex As Exception
MessageBox.Show("No data found")
FilterGrid.Visible = False
SalesDataGridView.Visible = True
End Try
Else
Dim dv As DataView
dv = New DataView(SilexDatabaseDataSet.Tables("Sales"), "", "Date Desc", DataViewRowState.CurrentRows)
FilterGrid.DataSource = dv
End If