VB数据库关闭问题

PublicSubtushumulu_Click()DimrsAsNewADODB.RecordsetDimconnAsNewADODB.ConnectionDimlin... Public Sub tushumulu_Click()
Dim rs As New ADODB.Recordset
Dim conn As New ADODB.Connection
Dim line
conn.Open "Provider = Microsoft.Jet.OLEDB.4.0;" & "Data Source = D:\工程1\DB1.mdb"
rs.Open "select * from book order by tushubianhao", conn, 1, 3
line = 0
Do While rs.EOF = False
line = line + 1
tushubianhao = rs.Fields(0)
tushumingcheng = rs.Fields(1)
zuozhexingming = rs.Fields(2)
chubanshe = rs.Fields(3)
chubanriqi = rs.Fields(4)
danjia = rs.Fields(5)
leibie = rs.Fields(6)
With tushuweihu.MSFlexGrid1
.Cols = 7
.Rows = line + 1
.TextMatrix(0, 0) = "图书编号"
.TextMatrix(0, 1) = "图书名称"
.TextMatrix(0, 2) = "作者姓名"
.TextMatrix(0, 3) = "出版社"
.TextMatrix(0, 4) = "出版日期"
.TextMatrix(0, 5) = "图书单价"
.TextMatrix(0, 6) = "图书类别"
.TextMatrix(line, 0) = tushubianhao
.TextMatrix(line, 1) = tushumingcheng
.TextMatrix(line, 2) = zuozhexingming
.TextMatrix(line, 3) = chubanshe
.TextMatrix(line, 4) = chubanriqi
.TextMatrix(line, 5) = danjia
.TextMatrix(line, 6) = leibie
.FixedRows = 1
.ColWidth(0) = 1100
.ColWidth(1) = 1100
.ColWidth(2) = 1100
.ColWidth(3) = 2100
.ColWidth(4) = 1300
.ColWidth(5) = 1100
.ColWidth(6) = 1100
End With
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Dim num_f As Integer
Dim num_l As Integer
Dim fgl_flg As Boolean
num_l = 0
fgl_flg = True
rs.Open "select tushubianhao from book ", conn, 1, 3
If rs.EOF = True Then
tushuweihu.Text1.Text = 1
Exit Sub
End If
Do While rs.EOF = False
If fgl_flg = False Then
num_l = rs.Fields(0)
If num_l - num_f <> 1 Then
tushuweihu.Text1.Text = num_f + 1
Exit Sub
End If
fgl_flg = True
Else
num_f = rs.Fields(0)
If num_f - num_l <> 1 Then
tushuweihu.Text1.Text = num_l + 1
Exit Sub
End If
fgl_flg = False
End If
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
If tushuweihu.Text1.Text = "" Then
rs.Open "select max(tushubianhao) from book", conn, 1, 3
tushuweihu.Text1.Text = rs.Fields(0) + 1
End If

tushuweihu.Text1.Enabled = False
tushuweihu.SSTab1.Tab = 0
'rs.Close 这里为什么加上去后,第一次点目录进去可以的,再点一次目录就提示对象已经关闭错误?再点的时候不是重新激活了事件,重新定义了RS对象吗?怎么会这样的呢? 请指点!
'Set rs = Nothing

End Sub
展开
 我来答
远风的梦想家
2009-02-18 · TA获得超过2550个赞
知道大有可为答主
回答量:1389
采纳率:0%
帮助的人:0
展开全部
肯定是已经被关闭过了
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式