| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 608 人关注过本帖, 1 人收藏
标题:修改ACCESS数据的求助
只看楼主 加入收藏
jsxygshh
Rank: 2
等 级:论坛游民
帖 子:20
专家分:10
注 册:2010-1-19
结帖率:60%
收藏(1)
已结贴  问题点数:0 回复次数:4 
修改ACCESS数据的求助
本人写了一段小代码,运行时出现"错误3705","打开对象时不允许操作"的错误,请大侠们帮助解决,十分感谢!在线等!!!
Option Explicit
Dim rs1 As New ADODB.Recordset, rs2 As New ADODB.Recordset     '定义数据集对象
Dim cnn As New ADODB.Connection     '定义数据连接
Dim i As Integer     '定义整型变量
Dim blnAdd As Boolean
Dim myval As Long

Private Sub Command1_Click()
rs2.Open "select * from 清单 where ID='" & Text1.Text & "'", cnn, adOpenKeyset, adLockOptimistic
    rs2.Fields("特征A1") = Combo1.Text
    rs2.Fields("特征B1") = Combo2.Text
    rs2.Fields("特征C1") = Combo3.Text
    rs2.Fields("特征D1") = Combo4.Text
    rs2.Fields("特征E1") = Combo5.Text
    rs2.Fields("特征F1") = Combo6.Text
    rs2.Fields("特征G1") = Combo7.Text
    rs2.Fields("特征H1") = Combo8.Text
    rs2.Fields("特征I1") = Combo9.Text
    rs2.Fields("特征J1") = Combo10.Text
    rs2.Update
rs2.Close
Unload Me
End Sub
Private Sub Form_Load()    '数据库连接
Text1.Text = 清单查询.Text1.Text
    cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=清单库.mdb;Persist Security Info=False"
    rs1.Open "清单 order by ID='" & Text1.Text & "'", cnn, adLockOptimistic
    'rs1.Refresh
    Text2.Text = rs1.Fields("项目名称")
    Text3.Text = rs1.Fields("单位")
   
    If rs1.Fields("特征A") <> "" Then
        Label1.Caption = rs1.Fields("特征A")
    Else
        Label1.Caption = ""
        Combo1.Visible = False
        'Label4.Caption = ""
    End If
    If rs1.Fields("特征B") <> "" Then
        Label2.Caption = rs1.Fields("特征B")
    Else
        Label2.Caption = ""
        Combo2.Visible = False
        'Label15.Caption = ""
    End If
    If rs1.Fields("特征C") <> "" Then
        Label3.Caption = rs1.Fields("特征C")
    Else
        Label3.Caption = ""
        Combo3.Visible = False
        'Label18.Caption = ""
    End If
    If rs1.Fields("特征D") <> "" Then
        Label4.Caption = rs1.Fields("特征D")
    Else
        Label4.Caption = ""
        Combo4.Visible = False
        'Label19.Caption = ""
    End If
    If rs1.Fields("特征E") <> "" Then
        Label5.Caption = rs1.Fields("特征E")
    Else
        Label5.Caption = ""
        Combo5.Visible = False
        'Label20.Caption = ""
    End If
    If rs1.Fields("特征F") <> "" Then
        Label6.Caption = rs1.Fields("特征F")
    Else
        Label6.Caption = ""
        Combo6.Visible = False
        'Label21.Caption = ""
    End If
    If rs1.Fields("特征G") <> "" Then
        Label7.Caption = rs1.Fields("特征G")
    Else
        Label7.Caption = ""
        Combo7.Visible = False
        'Label22.Caption = ""
    End If
    If rs1.Fields("特征H") <> "" Then
        Label8.Caption = rs1.Fields("特征H")
    Else
        Label8.Caption = ""
        Combo8.Visible = False
        'Label23.Caption = ""
    End If
    If rs1.Fields("特征I") <> "" Then
        Label9.Caption = rs1.Fields("特征I")
    Else
        Label9.Caption = ""
        Combo9.Visible = False
        'Label24.Caption = ""
    End If
    If rs1.Fields("特征J") <> "" Then
        Label10.Caption = rs1.Fields("特征J")
    Else
        Label10.Caption = ""
        Combo10.Visible = False
        'Label25.Caption = ""
    End If
   
   
    For i = 1 To 10
    If rs1.Fields("特征A" & i) <> "" Then
        Combo1.AddItem rs1.Fields("特征A" & i).Value
    End If
    If rs1.Fields("特征B" & i) <> "" Then
        Combo2.AddItem rs1.Fields("特征B" & i).Value
    End If
    If rs1.Fields("特征C" & i) <> "" Then
        Combo3.AddItem rs1.Fields("特征C" & i).Value
    End If
    If rs1.Fields("特征D" & i) <> "" Then
        Combo4.AddItem rs1.Fields("特征D" & i).Value
    End If
    If rs1.Fields("特征E" & i) <> "" Then
        Combo5.AddItem rs1.Fields("特征E" & i).Value
    End If
    If rs1.Fields("特征F" & i) <> "" Then
        Combo6.AddItem rs1.Fields("特征F" & i).Value
    End If
    If rs1.Fields("特征G" & i) <> "" Then
        Combo7.AddItem rs1.Fields("特征G" & i).Value
    End If
    If rs1.Fields("特征H" & i) <> "" Then
        Combo8.AddItem rs1.Fields("特征H" & i).Value
    End If
    If rs1.Fields("特征I" & i) <> "" Then
        Combo9.AddItem rs1.Fields("特征I" & i).Value
    End If
    If rs1.Fields("特征J" & i) <> "" Then
        Combo10.AddItem rs1.Fields("特征J" & i).Value
    End If
    Next i
    'Unload Me
End Sub
搜索更多相关主题的帖子: where 在线 
2011-09-17 06:40
jsxygshh
Rank: 2
等 级:论坛游民
帖 子:20
专家分:10
注 册:2010-1-19
收藏
得分:0 
补充附件
项目特征.zip (99.95 KB)
2011-09-17 06:45
zhuyongxing
Rank: 6Rank: 6
等 级:侠之大者
威 望:1
帖 子:234
专家分:482
注 册:2009-8-5
收藏
得分:3 
你上传的附近打不开加QQ远程帮您.308749442
2011-09-17 10:02
zhuyongxing
Rank: 6Rank: 6
等 级:侠之大者
威 望:1
帖 子:234
专家分:482
注 册:2009-8-5
收藏
得分:7 
rs 没关闭,cn没打开呵呵检查检查
2011-09-17 10:03
jsxygshh
Rank: 2
等 级:论坛游民
帖 子:20
专家分:10
注 册:2010-1-19
收藏
得分:0 
谢谢,问题解决了,是"rs 没关闭,cnn没有及时关闭"引起的.
2011-09-18 05:54
快速回复:修改ACCESS数据的求助
数据加载中...
 
   



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

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