我在vb中有一个函数,我正在将项目从1.1框架升级到4.0 它给出错误Set_item不是数据行的成员
Public Function CreateRow(ByVal [Text] As String, ByVal Value As String, ByVal dt As DataTable) As DataRow
Dim row2 As DataRow = dt.NewRow
row2.set_Item(0, [Text])
row2.set_Item(1, Value)
Return row2
End Function
答案 0 :(得分:0)
您可以使用以下SetField。 SetField(Of T)(x,value)其中x是DataTable中的序号位置或列名称。
Public Function CreateRow(ByVal [Text] As String, ByVal Value As String, ByVal dt As DataTable) As DataRow
Dim row2 As DataRow = dt.NewRow
row2.SetField(Of String)(0, [Text])
row2.SetField(Of String)(1, Value)
Return row2
End Function