对datagridview实现新增一行:
首先要把datagridview的datasource的值绑定一个dataset,
dataset.Tables("表的名称").Rows.Add("要插入对应列的字符串",".....","....")
对datagridview实现删除特定的一行:
datagridview.rows.remove(行的索引)
datagridview更新数据库:
对一个单击事件编写:
dim adapter as New OleDb.OleDbDataAdapter("select * from table", connection)
dim commandbuilder as new New OleDb.OleDbCommandBuilder(adapter)
With adapter
.InsertCommand = cber.GetInsertCommand
.DeleteCommand = cber.GetDeleteCommand
.UpdateCommand = cber.GetUpdateCommand
End With
Try
adapter.Update(dataset.Tables("table"))
dataset.AcceptChanges()
Catch ex As Exception
End Try