查看: 1143|回复: 8
|
vb6 link access不能save/update data
[复制链接]
|
|
偶弄了一個vb的student admision project(學校assignment)..
程序能load data..
但不能write new data在同一個access

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

這個填寫完后不能save wor..
嘗試過用以下的code..需要debug pula
- Private Sub cmdSave_Click()
- adodc1.Recordset.Fields("Name") = text1.Text
- adodc1.Recordset.Fields("ID") = text2.Text
- adodc1.Recordset.Fields("Address") = text3.Text
- adodc1.Recordset.Fields("City") = text4.Text
- adodc1.Recordset.Fields("State") = combo1.Text
- adodc1.Recordset.Fields("Tel") = text5.Text
- adodc1.Recordset.Fields("Course") = combo2.Text
- adodc1.Recordset.Fields("SPM") = combo3.Text
- adodc1.Recordset.Update
- End Sub
复制代码
注:
text1 = name
text2 = ID
text3 = address
text4 = tel
combo1 = state
combo2 = course
combo3 = SPM result
adodc1 = 第一個form的adodc(沒改到名)
那位可指點一下錯在哪裏leh..
謝謝 |
|
|
|
|
|
|
|
发表于 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
|
显示全部楼层
|
|
|
|
|
|
|
发表于 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(若我沒看錯的話啦)
- Private Sub cmdSave_Click()
- form2.adodc1.Recordset.Fields("Name") = text1.Text
- form2.adodc1.Recordset.Fields("ID") = text2.Text
- form2.adodc1.Recordset.Fields("Address") = text3.Text
- form2.adodc1.Recordset.Fields("City") = text4.Text
- form2.adodc1.Recordset.Fields("State") = combo1.Text
- form2.adodc1.Recordset.Fields("Tel") = text5.Text
- form2.adodc1.Recordset.Fields("Course") = combo2.Text
- form2.adodc1.Recordset.Fields("SPM") = combo3.Text
- form2.adodc1.Recordset.Update
- 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 编辑 ] |
|
|
|
|
|
|
|
发表于 14-8-2006 11:15 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 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 |
|
|
|
|
|
|
|
发表于 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...... |
|
|
|
|
|
|
| |
本周最热论坛帖子
|