'我动态建立了一个数据集和一个表还有2列.想往表里添加多条记录.一次添一条记录,每添完一次就刷新一下,在DATAGRID中显示出来.但是每次刷新在DATAGRID中得到的都是这一次添加的记录,以前添加的都没显示出来.只有显示一条.这是怎么回事.是不是我的数据集没有公用.哪位好人能帮一下.很感激
Dim myDataSet As DataSet Dim myDataTable As DataTable = New DataTable("attendtimetable") Dim myDataColumn As DataColumn Dim myDataRow As DataRow
'第一列 myDataColumn = New DataColumn myDataColumn.DataType = System.Type.GetType("System.String") myDataColumn.ColumnName = "date" myDataTable.Columns.Add(myDataColumn)
'第二列
myDataColumn = New DataColumn myDataColumn.DataType = System.Type.GetType("System.String") myDataColumn.ColumnName = "time" myDataTable.Columns.Add(myDataColumn)
myDataSet = New DataSet myDataSet.Tables.Add(myDataTable)
myDataRow = myDataTable.NewRow()
myDataRow("date") = TextBox7.Text myDataRow("time") = DateTime.Now myDataTable.Rows.Add(myDataRow) myDataSet.AcceptChanges() DataGrid3.DataSource = myDataSet.Tables("attendtimetable")