2
假設Customer表具有Address1和Address2列。用VS 2008嚮導創建類型化的DataSet 後,我寫了下面的代碼:ADO.NET DataTable.Merge()方法不能按預期方式工作
Dim t1 As MyDataSet.CustomerDataTable = New MyDataSet.CustomerDataTable
Dim r1 As MyDataSet.CustomerRow = t1.NewCustomerRow()
r1.Address1 = "a1"
t1.Rows.Add(r1)
Dim t2 As MyDataSet.CustomerDataTable = New MyDataSet.CustomerDataTable
Dim r2 As MyDataSet.CustomerRow = t2.NewCustomerRow()
r2.Address2 = "b1"
t2.Rows.Add(r2)
t1.Merge(t2, True)
Dim row As DataRow = t1.Rows(0)
Dim address2 As String = row("Address2")
我預期地址2等於「B1」,但它實際上包含了爲DBNull。爲什麼?