标题:高手帮帮忙。
只看楼主
weichun
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2005-2-24
 问题点数:0 回复次数:1 
高手帮帮忙。

我编的数据库程序在窗体上有增加和删除按钮,增加可以更新数据库,但为什么删除时不能更新?(没有出错信息,在datagrid1上当按删除钮时可看到数据跟着删除),代码如下: Public Class frmjbdw Inherits System.Windows.Forms.Form

Sub updatadw() cmdbuilder = New OleDbCommandBuilder(adpter) adpter.Update(ds.Tables("jbdw")) con.Close() DataGrid1.ReadOnly = True End Sub

Private Sub frmjbdw_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load opendb() If con.State = ConnectionState.Closed Then con.Open() adpter = New OleDbDataAdapter("select * from jbdw", con) ds = New DataSet adpter.Fill(ds, "jbdw") DataGrid1.ReadOnly = True DataGrid1.DataSource = ds.Tables("jbdw") con.Close()

End Sub

Private Sub Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

updatadw()

End Sub

Private Sub Cancl_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click con.Close() Me.Dispose() End Sub

Private Sub Delect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim rowno = DataGrid1.CurrentRowIndex ds.Tables("jbdw").Rows.Remove(ds.Tables("jbdw").Rows(rowno)) ds.Tables("jbdw").AcceptChanges()

updatadw()

End Sub End Class

搜索更多相关主题的帖子: 数据 数据库程序 
2005-03-31 22:41
ggvboy
Rank: 4
来 自:沈阳
等 级:贵宾
威 望:10
帖 子:142
专家分:0
注 册:2008-11-7
得分:0 
帖子太密集,看的很费力!
2008-11-10 14:43



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-14526-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.593949 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved