如何配置多个数据适配器?

时间:2014-12-21 19:14:14

标签: vb.net

以下代码可以正常使用。

Public Class DaisyServicesForm
    Dim ds As DataSet = New DataSet()

    Dim connStr As String = "server=inlt01\SQLEXPRESS; database=DaisyServices; integrated security=yes"
    Dim conn As SqlConnection = New SqlConnection(connStr)

    Dim sql As String = "SELECT t.[ID],t.[Site],t.[CLI],t.[CustomerName],t.[FromDate],t.[ToDate],t.[Quantity],t.[UnitCost],t.[TotalCost],t.[Description],t.[filenameonly],t.billingmonth as [CurrentBillingMonth], [bill] FROM [DaisyServices].[dbo].[DaisyServicesIndigo] t"
    Dim comm As SqlCommand = New SqlCommand(sql, conn)
    Dim dataadapter As SqlDataAdapter = New SqlDataAdapter(comm)

但由于某种原因,当我添加其他数据适配器时,如下所示,我收到以下错误

"对象引用未设置为对象的实例。"

Public Class DaisyServicesForm
    Dim ds As DataSet = New DataSet()

    Dim connStr As String = "server=inlt01\SQLEXPRESS; database=DaisyServices; integrated security=yes"
    Dim conn As SqlConnection = New SqlConnection(connStr)

    Dim sql As String = "SELECT t.[ID],t.[Site],t.[CLI],t.[CustomerName],t.[FromDate],t.[ToDate],t.[Quantity],t.[UnitCost],t.[TotalCost],t.[Description],t.[filenameonly],t.billingmonth as [CurrentBillingMonth], [bill] FROM [DaisyServices].[dbo].[DaisyServicesIndigo] t"
    Dim comm As SqlCommand = New SqlCommand(sql, conn)
    Dim dataadapter As SqlDataAdapter = New SqlDataAdapter(comm)

    Dim sql2 As String = "SELECT i.[ID],i.[Site],i.[CLI],i.[CustomerName],i.[FromDate],i.[ToDate],i.[Quantity],i.[UnitCost],i.[TotalCost],i.[Description],i.[filenameonly],i.billingmonth as [CurrentBillingMonth], i.[bill] From [DaisyServices].[dbo].[DaisyServicesIndigo] i LEFT JOIN [DaisyServices].[dbo].[" + TextBox1.Text + "] s on i.[SITE]=s.[SITE] AND i.[CLI]=s.[CLI] AND i.[Quantity]=s.[Quantity] AND i.[UnitCost]=s.[UnitCost] AND i.[TotalCost]=s.[TotalCost] AND i.[Description]=s.[Description] WHERE s.[CLI] is NULL"
    Dim comm2 As SqlCommand = New SqlCommand(sql2, conn)
    Dim dataadapter2 As SqlDataAdapter = New SqlDataAdapter(comm2)

    Dim sql3 As String = "SELECT s.[ID],s.[Site],s.[CLI],s.[CustomerName],s.[FromDate],s.[ToDate],s.[Quantity],s.[UnitCost],s.[TotalCost],s.[Description],s.[filenameonly],s.billingmonth as [CurrentBillingMonth], s.[bill] From [DaisyServices].[dbo].[" + TextBox1.Text + "] s LEFT JOIN [DaisyServices].[dbo].[DaisyServicesIndigo] i on i.[SITE]=s.[SITE] AND i.[CLI]=s.[CLI] AND i.[Quantity]=s.[Quantity] AND i.[UnitCost]=s.[UnitCost] AND i.[TotalCost]=s.[TotalCost] AND i.[Description]=s.[Description] WHERE i.[CLI] is NULL"
    Dim comm3 As SqlCommand = New SqlCommand(sql3, conn)
    Dim dataadapter3 As SqlDataAdapter = New SqlDataAdapter(comm3)

如何在同一表单上配置多个适配器?

由于

0 个答案:

没有答案