以编程方式从DataGridView添加和删除记录 [英] adding and deleting records from DataGridView programatically
本文介绍了以编程方式从DataGridView添加和删除记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在vb.net2005中,我想使用MSAccess 2007中的数据源以编程方式从DataGridView中添加和删除记录,并且数据库包含基于日期/时间和是/否的字段.
用于删除我正在使用的行
In vb.net2005 i want to add and delete records programatically from DataGridView using datasource from MSAccess 2007 , and database contains fields based on date/time and yes/no .
for deleting rows i am using
Dim cmd As OleDbCommandBuilder
cmd = New OleDbCommandBuilder(da)
Dim dt As New DataTable
dt = ds.Tables(0)
dt.Rows(DataGridView1.SelectedRows(0).Index()).Delete()
da.Update(dt)
ds.AcceptChanges()
并添加我正在使用的记录
and to add records i am using
Dim cmd As OleDbCommandBuilder
Dim changes As DataSet
cmd = New OleDbCommandBuilder(da)
changes = ds.GetChanges()
If changes IsNot Nothing Then
da.Update(ds.Tables(0))
End If
ds.AcceptChanges()
两者都没有日期和是/否字段工作,但是当包含这些字段时我出错了,
我可以知道如何添加&吗?包括日期时删除
感谢和问候
both are working without date and yes/no fields ,but when these included then i am getting error,
can i know how to add & delete when date included
thanks and regards
推荐答案
尝试
使用分页在DataGridView中添加,编辑和删除 [在DataGridView中添加,编辑和删除 [
Try
Add, Edit, and Delete in DataGridView with Paging[^]
Add, Edit, and Delete in DataGridView[^]
试试这个:
带有详细信息编辑表单的DataGridView-VS 2005
Try this one :
DataGridView with Detail Edit Form - VS 2005
这篇关于以编程方式从DataGridView添加和删除记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文