0

我有一个运行查询的 VB.net 程序。该查询有时会提取数十万条记录。到目前为止,我已经向 reportviewer 报告了查询报告,然后我在表单上有第二个按钮,用于将数据集导出到 .csv 文件。这一切都像宣传的那样工作,但它并未显示所有记录。如果我运行查询而不将信息存储在数据集中,我会得到超过 1,000 个结果。

当我运行程序时,我只得到 568 个结果。我的假设是使用程序中的“填充”命令此信息太大。如何更改它以显示数据集中的所有记录,无论是在报告查看器中,还是在选择“导出”按钮时。

这是我的查询:

SELECT        Invoice_Tb.Customer_First_Name AS firstname, Invoice_Tb.Customer_Last_Name AS lastname, Invoice_Tb.Customer_Address AS add1, Invoice_Tb.City, 
                         Invoice_Tb.Customer_State AS State, LEFT(Invoice_Tb.ZIP_Code, 5) AS ZIP, Invoice_Tb.Customer_Email_Address AS [Email Address], 
                         Invoice_Tb.Vehicle_Mileage AS [Vehicle Mileage], Invoice_Tb.Invoice_Date AS [Date Of Service], Invoice_Tb.Store_Number, @startdate AS Start_Date, 
                         @enddate AS End_Date
FROM            Invoice_Detail_Tb INNER JOIN
                         Invoice_Tb ON Invoice_Detail_Tb.Invoice_Number = Invoice_Tb.Invoice_Number AND Invoice_Detail_Tb.Invoice_Date = Invoice_Tb.Invoice_Date
WHERE        (Invoice_Detail_Tb.Store_Category_Code = 'FS') AND (Invoice_Tb.Invoice_Date BETWEEN CONVERT(DATETIME, @startdate, 102) AND CONVERT(Datetime, 
                         @enddate, 102)) AND (Invoice_Tb.Reminder_Mail_Flag = 'Y')

这是我将结果拉到报表查看器的按钮代码:

Me.Invoice_TbTableAdapter.Fill(Me.DataDeliveryServiceDataSet.Invoice_Tb, startdatepicker.Value, enddatepicker.Value)


        Me.ReportViewer1.RefreshReport()

这是我的“导出”到 csv 按钮代码:

Dim str As New StringBuilder

        For Each dr As DataRow In Me.DataDeliveryServiceDataSet.Invoice_Tb

            For Each field As Object In dr.ItemArray

                str.Append(field.ToString & ",")

            Next

            str.Replace(",", vbNewLine, str.Length - 1, 1)

        Next



        Try

            My.Computer.FileSystem.WriteAllText("C:\temp\testcsv.csv", str.ToString, False)

        Catch ex As Exception

            MessageBox.Show("Write Error")

        End Try

知道如何让所有记录显示吗?

4

0 回答 0