' System.InvalidOperationException'发生在System.Data.DataSetExtensions.dll VB.Net中

时间:2015-12-23 12:35:25

标签: vb.net exception

我使用此代码从数据库中获取数据。在其他条件下,如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

0 个答案:

没有答案