以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  new list(of datarow) add出错  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=189517)

--  作者:lur320
--  发布时间:2023/12/6 10:19:00
--  new list(of datarow) add出错
    如下,想把新增的datarow加入到一个空集合。但是 xinrows.add(dr)这里出错,显示未将对象引用设置到对象的实例。MessageBox.Show(1)正常, MessageBox.Show(2)没显示。


        Dim xinrows As List(Of DataRow)
        For i As Integer = 0 To 100
            Select Case sheet(0, i).Text.Trim
                Case ""
                    Exit For
                Case "检验单号"
                    checkNO = sheet(1, i).Text
                Case "批号"
                    batchno = sheet(1, i).Text
                Case Else
                    Dim dr As DataRow = DataTables("QC数据").AddNew
              
                    dr("文件名称") = FileSys.GetName(file)
                   
                    dr("修改日期") = ifo.LastWriteTime
                    dr.save
                    MessageBox.Show(1)
                    xinrows.add(dr)
                   MessageBox.Show(2)

            End Select
        Next
        MessageBox.Show(3)
        For Each dr As DataRow In xinrows
            dr("") = batchno
           
        Next
--  作者:lur320
--  发布时间:2023/12/6 10:29:00
--  
 Dim xinrows As new List(Of DataRow)  要加new