各位大侠,我遇到了一个奇怪的问题????

qw12380 2003-11-19 04:13:17
我写了一个标准模块,在main内声明打开了连接和记录集,并在form1中调用。当我向form1的文本框赋值时提示一下错误信息:

实时错误 ‘3021’:
BOF 或 EOF中有一个是“真”,或者当前的记录已经删除,所需的操作要求一个当前的记录。

请帮忙给看看吧!!!! ^_^

/**************************
* 这是标准模块中的代码 *
**************************/
Option Explicit


Public conn As New ADODB.Connection
Public Ress As New ADODB.Recordset
Public Ress2 As New ADODB.Recordset

Private Sub main()


conn = "Provider=SQLOLEDB.1;Password=*******;Persist Security Info=True;User ID=sa;Initial Catalog=newmark;Data

Source=SUNFLOWER"
conn.Open
Ress.Open "test", conn, adOpenKeyset, adLockPessimistic

form1.Show

End Sub

Public Sub close_conn()
conn.Close
End Sub
/***************************
* 这是form1中的代码 *
***************************/
Private Sub command1_Click()
Dim into_val As String
Dim find_str As String

Text1.Text = ""
Text2.Text = ""
Text3.Text = ""


into_val = InputBox("请输入要查找的一卡通卡号", "精确查找")
If into_val = Empty Then
MsgBox "查询条件不能为空!!!!"
into_val = InputBox("请输入要查找的一卡通卡号", "精确查找")
End If
find_str = "select * from huiyuanxinxi where cuno='into_cal' ;"
Ress2.Open find_str, conn, adOpenKeyset, adLockPessimistic
If Ress.EOF And Ress.BOF Then
MsgBox "invalid couresid", vbOKOnly, "stop!!!"
Exit Sub
End If

/*******************************
* 问题出现在下面的赋值部分 *
*******************************/
Text1.Text = Ress2.Fields("aaa")
Text2.Text = Ress2.Fields("bbb")
Text3.Text = Ress2.Fields("ccc")



Ress.MoveNext
If Ress.EOF Then
Ress.MoveFirst
End If
Call close_conn
end sub
...全文
46 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
nfsxy 2003-11-19
  • 打赏
  • 举报
回复
find_str = "select * from huiyuanxinxi where cuno='into_cal' ;"
Ress2.Open find_str, conn, adOpenKeyset, adLockPessimistic
这两句改为:
find_str = "select * from huiyuanxinxi where cuno=" & into_cal
Ress2.Open find_str, conn, adOpenstatic, adLockPessimistic

1,217

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧