佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1145|回复: 8

vb6 link access不能save/update data

[复制链接]
发表于 13-8-2006 09:13 PM | 显示全部楼层 |阅读模式
偶弄了一個vb的student admision project(學校assignment)..
程序能load data..
但不能write new data在同一個access


儅按了add new就會link到下面的form


這個填寫完后不能save wor..

嘗試過用以下的code..需要debug pula

  1. Private Sub cmdSave_Click()
  2. adodc1.Recordset.Fields("Name") = text1.Text
  3. adodc1.Recordset.Fields("ID") = text2.Text
  4. adodc1.Recordset.Fields("Address") = text3.Text
  5. adodc1.Recordset.Fields("City") = text4.Text
  6. adodc1.Recordset.Fields("State") = combo1.Text
  7. adodc1.Recordset.Fields("Tel") = text5.Text
  8. adodc1.Recordset.Fields("Course") = combo2.Text
  9. adodc1.Recordset.Fields("SPM") = combo3.Text
  10. adodc1.Recordset.Update

  11. End Sub
复制代码


注:
text1 = name
text2 = ID
text3 = address
text4 = tel
combo1 = state
combo2 = course
combo3 = SPM result
adodc1 = 第一個form的adodc(沒改到名)

那位可指點一下錯在哪裏leh..
謝謝
回复

使用道具 举报


ADVERTISEMENT

发表于 13-8-2006 11:16 PM | 显示全部楼层
error message 是什么?

可能adodc1是在View Profile的form,所以你要....

>>formViewProfile.adodc1.recordset......

[ 本帖最后由 haroldlbc 于 13-8-2006 11:20 PM 编辑 ]
回复

使用道具 举报

发表于 14-8-2006 12:58 AM | 显示全部楼层
是否少了

adodc1.recordset.addnew
回复

使用道具 举报

发表于 14-8-2006 09:04 AM | 显示全部楼层
原帖由 hooi1983 于 14-8-2006 12:58 AM 发表
是否少了


他的 addnew 在 view profile form里。
回复

使用道具 举报

 楼主| 发表于 14-8-2006 04:31 PM | 显示全部楼层
原帖由 haroldlbc 于 13-8-2006 11:16 PM 发表
error message 是什么?

可能adodc1是在View Profile的form,所以你要....

>>formViewProfile.adodc1.recordset......


Edited:
現在能用了..用了醬的code
還發現若那些field沒填完就一定有error的..
還有就是field name不能space(若我沒看錯的話啦)

  1. Private Sub cmdSave_Click()
  2. form2.adodc1.Recordset.Fields("Name") = text1.Text
  3. form2.adodc1.Recordset.Fields("ID") = text2.Text
  4. form2.adodc1.Recordset.Fields("Address") = text3.Text
  5. form2.adodc1.Recordset.Fields("City") = text4.Text
  6. form2.adodc1.Recordset.Fields("State") = combo1.Text
  7. form2.adodc1.Recordset.Fields("Tel") = text5.Text
  8. form2.adodc1.Recordset.Fields("Course") = combo2.Text
  9. form2.adodc1.Recordset.Fields("SPM") = combo3.Text
  10. form2.adodc1.Recordset.Update

  11. End Sub
复制代码


多謝老兄..現在一切ok了..thanks

[ 本帖最后由 dalaroix 于 14-8-2006 09:06 PM 编辑 ]
回复

使用道具 举报

发表于 14-8-2006 10:23 PM | 显示全部楼层
以后命名要命好来,
要救才容易。

其实可以....

With form2.adodc1

  .Recordset.Fields("Name") = text1.Text
  .Recordset.Fields("ID") = text2.Text
  .Recordset.Fields("Address") = text3.Text
  .Recordset.Fields("City") = text4.Text
  .Recordset.Fields("State") = combo1.Text
  .Recordset.Fields("Tel") = text5.Text
  .Recordset.Fields("Course") = combo2.Text
  .Recordset.Fields("SPM") = combo3.Text
  .Recordset.Update

End With

[ 本帖最后由 haroldlbc 于 14-8-2006 10:25 PM 编辑 ]
回复

使用道具 举报

Follow Us
发表于 14-8-2006 11:15 PM | 显示全部楼层
来参考我以前的project,
我也是用ADODC。。。。。。

http://chinese2.cari.com.my/myforum/viewthread.php?tid=625224
回复

使用道具 举报

发表于 15-8-2006 01:58 PM | 显示全部楼层
原帖由 haroldlbc 于 14-8-2006 10:23 PM 发表
以后命名要命好来,
要救才容易。

其实可以....

With form2.adodc1

  .Recordset.Fields("Name") = text1.Text
  .Recordset.Fields("ID") = text2.Text
  .Recordset.Fields(&q ...

其实可以....

With form2.adodc1.Recordset

  .Fields("Name") = text1.Text
  .Fields("ID") = text2.Text
  .Fields("Address") = text3.Text
  .Fields("City") = text4.Text
  .Fields("State") = combo1.Text
  .Fields("Tel") = text5.Text
  .Fields("Course") = combo2.Text
  .Fields("SPM") = combo3.Text
  .Update

End With



With form2.adodc1

  .Recordset("Name") = text1.Text
  .Recordset("ID") = text2.Text
  .Recordset("Address") = text3.Text
  .Recordset("City") = text4.Text
  .Recordset("State") = combo1.Text
  .Recordset("Tel") = text5.Text
  .Recordset("Course") = combo2.Text
  .Recordset("SPM") = combo3.Text
  .Recordset.Update

End With
回复

使用道具 举报


ADVERTISEMENT

发表于 15-8-2006 03:25 PM | 显示全部楼层
原帖由 chu10 于 15-8-2006 01:58 PM 发表

其实可以....

With form2.adodc1.Recordset

  .Fields("Name") = text1.Text
  .Fields("ID") = text2.Text
  .Fields("Address") = text3.Text
  .Fields("City& ...

老实说,既然他已经用了adodc的control在form1,就干脆在textbox的properties那里可以set datasource = adodc1,那么code就只有一个,那就是:

adodc1.recordset.update

可是他把add的分开去另一个form所以才那么麻烦。

不懂为何不放在同一个form......
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 26-8-2025 05:01 AM , Processed in 0.117376 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表