添加新行到DataSet

Dim myadapter As New SqlDataAdapter(sqlstr, Conn)
Dim ds As New DataSet
myadapter.Fill(ds, 
"price")
 
'在最后添加
Dim rh As DataRow
rh 
= ds.Tables("price").NewRow
rh.Item(
0= "合计:"
rh.Item(
"金额"= ds.Tables("price").Compute("sum(金额)""")
ds.Tables(
"price").Rows.Add(rh)
 
'插入到指定行
Dim newRow As DataRow = Tables("price").NewRow();
newRow(
"字段"= "内容1"
newRow(
"字段"= "内容2"
Tables(
"price").Rows.InsertAt(newRow, a); 'a为要插入的行号(int型)
原文地址:https://www.cnblogs.com/ryb/p/737177.html