| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1497 人关注过本帖
标题:[求助]ado非控件查询报实时错误424,要求对象,请指教
取消只看楼主 加入收藏
basswood
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-10-6
收藏
 问题点数:0 回复次数:3 
[求助]ado非控件查询报实时错误424,要求对象,请指教

我在网上找了一下相关的帖子,还是不得其解,请各位指点:
Private Sub Form_Load()
Dim conStr As String

Set conn = New ADODB.Connection
Set rst = New ADODB.Recordset
conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\data.mdb;Persist Security Info=False"

conn.Open conStr
With rst
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
End With

rst.Open "stuInfo", conn, , , adCmdTable

Set DBG1.DataSource = rst

End Sub

Private Sub Comname_Click()
Dim strsele As String
If txtName.Text = " " Then
MsgBox "姓名不能为空!", vbOKOnly, "提示信息"
txtName.SetFocus
End If

strsele = "select * from stuInfo Where name='" & trim(txtName.Text) & " '"

Set rst = conn.Execute(strsele)

End Sub


运行到Set rst = conn.Execute(strsele)报424错。

能否帮我加上相关代码

搜索更多相关主题的帖子: ado 控件 Microsoft 实时 对象 
2006-10-06 11:59
basswood
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-10-6
收藏
得分:0 
谢谢,我改了一下,,加入了
Private conn As ADODB.Connection
Private rst As ADODB.Recordset
现在报实时错误3705,对像打开时,不充许操作
Private Sub Comname_Click()
Dim strsplx As String
Dim strcpdate1 As Date
Dim strcpdate2 As Date
Dim strpfdate1 As Date
Dim strpfdate2 As Date
Dim strsele As String
If Txtname.Text = " " Then
MsgBox "姓名不能为空!", vbOKOnly, "提示信息"
Txtname.SetFocus
End If
strsele = "select * from stuInfo Where name='" & Trim(Txtname.Text) & " '"

Set rst = conn.Execute(strsele)

rst.Open strsele, conn, adOpenDynamic, adLockOptimistic

If rst.EOF Then
Set DBG1.DataSource = rst
End If
运行到:rst.Open strsele, conn, adOpenDynamic, adLockOptimistic
就报错。请再指教,谢谢。
2006-10-06 14:16
basswood
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-10-6
收藏
得分:0 
现在不报任何错,但返回的不是我需要的记录,查询前后的数据没有任何变化。
Private Sub Comname_Click()
Dim strsplx As String
Dim strcpdate1 As Date
Dim strcpdate2 As Date
Dim strpfdate1 As Date
Dim strpfdate2 As Date
Dim strsele As String
If Txtname.Text = " " Then
MsgBox "姓名不能为空!", vbOKOnly, "提示信息"
Txtname.SetFocus
End If
strsele = "select * from stuInfo Where name='" & Trim(Txtname.Text) & " '"

Set rst = conn.Execute(strsele)
rst.Close
rst.Open strsele, conn, adOpenDynamic, adLockOptimistic
rst.Requery

If rst.EOF Then
Set DBG1.DataSource = rst
End If


End Sub
2006-10-06 14:32
basswood
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2006-10-6
收藏
得分:0 
感谢“学习VB才2天”,按你的提示,问题已解决。顺便问题一下,任何结贴?
2006-10-06 14:49
快速回复:[求助]ado非控件查询报实时错误424,要求对象,请指教
数据加载中...
 
   



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

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