VB.NET SQL查询结果集不同

时间:2015-09-28 03:10:37

标签: sql-server vb.net

我正在从SQL读取数据到我的vb.net程序中,并且在运行应用程序时收到的数据不正确。因此我简化了我的查询以诊断,当我在我的SQL管理工作室上运行代码时,我获得了2288个结果但是当我在我的应用程序中运行相同的代码时,我只获得了1872个结果。

SQL代码:

SELECT * FROM invoiceItem 
left join invoice on invoice.invoiceno = invoiceitem.invoiceno
where invoice.customer = 'aaapal'

VB.NET代码

Dim SQL As String
SQL = "SELECT * FROM invoiceItem " & _
        "left join invoice on invoice.invoiceno = invoiceitem.invoiceno " & _
        "WHERE invoice.customer = 'aaapal'"
Dim DT As New DataTable
Try
    Dim con As New SqlConnection(My.Settings.TSMT_DBConnectionString)
    Dim da As SqlDataAdapter = New SqlDataAdapter(SQL, con)
    da.Fill(DT)
    MessageBox.Show(DT.Rows.Count)
Catch ex As Exception
    MessageBox.Show(ex.ToString, "Error Loading top 10 Products", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try

Return DT

有关可能导致此问题的任何建议吗?

0 个答案:

没有答案