小妹子请问各位大哥,在vb中ado的recordset对象,对记录如何进行编辑?(不许笑哦!)

lhh 2001-11-30 03:23:22
添加记录的流程是:
rs.addnew
rs.fields(index).value=***
*****
rs.update
但我没有发现rs 有edit方法,请各位大哥指教!
小妹子有礼了!~
...全文
218 19 打赏 收藏 举报
写回复
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
810303 2001-11-30
  • 打赏
  • 举报
回复
不要告诉我不会给
810303 2001-11-30
  • 打赏
  • 举报
回复
给点分噻!虽然你是MM,也不能不给分耶!
lonaerd 2001-11-30
  • 打赏
  • 举报
回复
LHH是女的????多大了?在哪挣钱?
lonaerd 2001-11-30
  • 打赏
  • 举报
回复
那肯定错啦,对种子的字段是不能编辑的,你不要给这个种子字段作任何修改。
dbcontrols 2001-11-30
  • 打赏
  • 举报
回复
只要说明自己是小妹子,哈哈,大哥们的腿跟你的心一样软.
lhh 2001-11-30
  • 打赏
  • 举报
回复
谢谢大家,我现在不用edit,就update,再加上810303的requery方法,就不报错了,谢谢各位大哥!
vcbug 2001-11-30
  • 打赏
  • 举报
回复
哈哈哈,我也想笑,帮你up一下哦,多好的小妹妹啊:)
810303 2001-11-30
  • 打赏
  • 举报
回复
是不是权限的设置有问题?
810303 2001-11-30
  • 打赏
  • 举报
回复
只要这样:
adoTempRS.Open "select * from S_CPSCSJGYWTFKDMX where S_cpscsjgywtfkdmx_xh='" & grdMX.TextMatrix(grdMX.row, 2) & "' and S_cpscsjgywtfkdmx_zbxh='" & txtFields(0).Text & "'", cnn, adOpenDynamic, adLockOptimistic
adoTempRS.Fields("S_cpscsjgywtfkdmx_xh").Value = grdMX.TextMatrix(grdMX.row, 2)
adoTempRS!S_cpscsjgywtfkdmx_zbxh = txtFields(0).Text
adoTempRS!S_cpscsjgywtfkdmx_ph = txtPH.Text
adoTempRS!S_cpscsjgywtfkdmx_pl= txtPL.Text
adoTempRS!S_cpscsjgywtfkdmx_fkwt= txtFKWT.Text
adoTempRS!S_cpscsjgywtfkdmx_fl= ComFL.Text
adoTempRS!S_cpscsjgywtfkdmx_jqs= txtSL.Text
adoTempRS!S_cpscsjgywtfkdmx_sfrbjs = ComRBJS.Text
adoTempRS!S_cpscsjgywtfkdmx_tbr = txtTBR.Text
adoTempRS!S_cpscsjgywtfkdmx_tbrq = txtTBRQ.Text
adoTempRS!S_cpscsjgywtfkdmx_sh = txtSH.Text
adoTempRS!S_cpscsjgywtfkdmx_pz = txtPZ.Text
adoTempRS!S_cpscsjgywtfkdmx_bz = txtBZ.Text
adoTempRS!S_cpscsjgywtfkdmx_sjsyj = txtSJSYJ.Text
adoTempRS!S_cpscsjgywtfkdmx_qm = txtSJS.Text
adoTempRS.Update
ADOTEMPRS.Requery
lhh 2001-11-30
  • 打赏
  • 举报
回复
我用的SQL Server 2000数据库服务器,不过操作的这个表里又一个序号被设置成了“种子”,可能跟它有关,以前我用这些方法都不出错的。
lhh 2001-11-30
  • 打赏
  • 举报
回复
我用的SQL Server 2000数据库服务器,不过操作的这个表里又一个序号被设置成了“种子”,可能跟它有关,以前我用这些方法都不出错的。
lhh 2001-11-30
  • 打赏
  • 举报
回复
我马上又回来了,我又试了,现在它报错“编辑记录失败!”,我看数据已经存进去了呀,但它就是要on error,不知道怎么回事?
810303 2001-11-30
  • 打赏
  • 举报
回复
用ADO+ACCESS吗?还是别的?
WxmJun 2001-11-30
  • 打赏
  • 举报
回复
数据表定义了主关键字没有?

其实这主关键字,没有它有时会更新了不的.
我也搞不懂它是否是必要的.

另:请不要把性别特意显示出来,我对此有点反感的!!
sqstudio_zsp 2001-11-30
  • 打赏
  • 举报
回复
哈哈哈哈
俺除了在这笑笑
好像没别的忙可以帮了
lhh 2001-11-30
  • 打赏
  • 举报
回复
我刚刚用过了,不用edit就update,但它报多步操作错误!无法更新!
我的定义是:
Dim WithEvents adoTempRS As Recordset
If txtPH <> "" And txtPL.Text <> "" And ComFL.Text <> "" And _
txtSL.Text <> "" And ComRBJS.Text <> "" And txtFKWT.Text <> "" And _
txtSJSYJ.Text <> "" And txtTBR.Text <> "" And txtTBRQ.Text <> "" Then
On Error GoTo err:
Set adoTempRS = New Recordset
adoTempRS.Open "select * from S_CPSCSJGYWTFKDMX where S_cpscsjgywtfkdmx_xh='" & grdMX.TextMatrix(grdMX.row, 2) & "' and S_cpscsjgywtfkdmx_zbxh='" & txtFields(0).Text & "'", cnn, adOpenDynamic, adLockOptimistic
adoTempRS.Fields("S_cpscsjgywtfkdmx_xh").Value = grdMX.TextMatrix(grdMX.row, 2)
adoTempRS.Fields("S_cpscsjgywtfkdmx_zbxh").Value = txtFields(0).Text
adoTempRS.Fields("S_cpscsjgywtfkdmx_ph").Value = txtPH.Text
adoTempRS.Fields("S_cpscsjgywtfkdmx_pl").Value = txtPL.Text
adoTempRS.Fields("S_cpscsjgywtfkdmx_fkwt").Value = txtFKWT.Text
adoTempRS.Fields("S_cpscsjgywtfkdmx_fl").Value = ComFL.Text
adoTempRS.Fields("S_cpscsjgywtfkdmx_jqs").Value = txtSL.Text
adoTempRS.Fields("S_cpscsjgywtfkdmx_sfrbjs").Value = ComRBJS.Text
adoTempRS.Fields("S_cpscsjgywtfkdmx_tbr").Value = txtTBR.Text
adoTempRS.Fields("S_cpscsjgywtfkdmx_tbrq").Value = txtTBRQ.Text
adoTempRS.Fields("S_cpscsjgywtfkdmx_sh").Value = txtSH.Text
adoTempRS.Fields("S_cpscsjgywtfkdmx_pz").Value = txtPZ.Text
adoTempRS.Fields("S_cpscsjgywtfkdmx_bz").Value = txtBZ.Text
adoTempRS.Fields("S_cpscsjgywtfkdmx_sjsyj").Value = txtSJSYJ.Text
adoTempRS.Fields("S_cpscsjgywtfkdmx_qm").Value = txtSJS.Text
adoTempRS.Update
UpdateEditMx = True
Else
UpdateEditMx = False
End If
err:
MsgBox "编辑记录失败!" & err.Description, vbCritical, "错误" '& err.Description

它运行到 adoTempRS.Fields("S_cpscsjgywtfkdmx_xh").Value = grdMX.TextMatrix(grdMX.row, 2) 就错了!
baoxiang 2001-11-30
  • 打赏
  • 举报
回复
ado控件默认的就是edit状态。
所以,不需要edit方法。
daryl715 2001-11-30
  • 打赏
  • 举报
回复
data1.recordset.edit
data1.recordset.field(0)="33"
data1.recordset.field(1)="66"
data1.recordset.update
data1.refresh

data1.recordset.addnew是用来新增记录,不是修改记录

岂能尽如人意,但求无愧我心,很高兴认识大家!
QQ:341157
E-mail:daryl@ihw.com.cn

Richard2001 2001-11-30
  • 打赏
  • 举报
回复
不用Edit.
rs.fields(index).value=***
rs.update
就行了。

相关推荐
发帖
VB基础类

7681

社区成员

VB 基础类
社区管理员
  • VB基础类社区
加入社区
帖子事件
创建了帖子
2001-11-30 03:23
社区公告
暂无公告