标题:datagrid 的问题
只看楼主
guyan1009
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2006-5-15
 问题点数:0 回复次数:0 
datagrid 的问题
我用datagrid与表绑定,然后通过双击datagrid的列来调用一个FORM窗体,上面显示datagrid的数据.想通过FOME修改datagrid数据,但保存老出错误!请高手指点.
这是保存按扭的代码
Private Sub Command1_Click()
Dim sql As String
sqltxt = "select * from jgz"
Set brs = exesql(sqltxt)
brs.Fields("员工编号") = Trim(Text2.Text)
brs.Fields("员工姓名") = Text1.Text
brs.Fields("部门") = Text3.Text
brs.Fields("产品编号") = Text4.Text
brs.Fields("产品名称") = Text5.Text
brs.Fields("工序编号") = Text6.Text
brs.Fields("工序名称") = Text7.Text
brs.Fields("合格数") = Text8.Text
brs.Fields("单价") = Text9.Text
brs.Fields("合计金额") = Text10.Text
brs.Fields("日期") = DTPicker1.Value
brs.Update
MsgBox "保存成功!", vbOKOnly, "提示"
Text2.Text = ""
Text8.Text = ""
Text1.Text = ""
Text3.Text = ""
Text2.SetFocus
Text10.Text = ""
End Sub
Public Function exesql(ByVal sql As String) As ADODB.Recordset
sql = Trim$(sql)
Dim conn As ADODB.Connection
Dim rst As ADODB.Recordset
Set conn = New ADODB.Connection
conn.Open "Provider=microsoft.jet.oledb.4.0;data source=" & App.Path & "\d.mdb"
Set rst = New ADODB.Recordset
Set rst.ActiveConnection = conn
rst.CursorType = adOpenDynamic
rst.LockType = adLockPessimistic
rst.Open sql
Set exesql = rst
Set rst = Nothing
Set conn = Nothing
End Function
搜索更多相关主题的帖子: datagrid 
2007-04-21 22:37



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




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

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