急死了就差一点了!大家快帮忙呀!!!

bluesanke 2003-04-04 01:41:40
Option Explicit
Dim Mycn As New ADODB.Connection '数据库连接对象,用于打开数据库
Dim Myrs1 As New ADODB.Recordset '记录集对象,用于存入记录的
Private Sub Command1_Click()
Dim cnstring As String '用于存放连接字符串的
cnstring = "Provider=OraOLEDB.Oracle.1;Persist Security Info=False;User ID=dytd;PassWord=dytd;Data Source=dytd"
Mycn.Open cnstring
Mycn.CursorLocation = adUseClient
If Option1.Value = True Then
If Text1.Text = "" Then
MsgBox "请正确填写申请书编号!", vbOKOnly + vbExclamation, "信息提示"
Exit Sub
Else
Myrs1.Open "select * from DJ_CSDJ_TDDJSQS where DCT_BH='" & Trim(Text1) & "'", Mycn
If Myrs1.BOF And Myrs1.EOF Then
MsgBox "不存在申请书编号!!!", vbOKOnly + vbExclamation, "信息提示"

Text1 = ""
Text1.SetFocus
Myrs1.Close
Set Myrs1 = Nothing
Mycn.Close
Exit Sub
End If
MSHFlexGrid1.Clear
TableInit
MSHFlexGrid1.Rows = MSHFlexGrid1.Rows + 1
MSHFlexGrid1.Row = MSHFlexGrid1.Rows - 1
MSHFlexGrid1.Col = 0
MSHFlexGrid1.Text = Myrs1.Fields("DCT_BH") & ""
MSHFlexGrid1.Col = 1
.....................
Myrs1.Close
Set Myrs1 = Nothing
Else
Mycn.Close '关闭连接对象
Set Mycn = Nothing
Myrs1.Close
Set Myrs1 = Nothing
Exit Sub
Mycn.Close
End If
Mycn.Close
.............
在后面加
If Option2.Value = True Then
怎样写代码呀!就差一点就好了!!!快帮忙呀!
昨天兰色情调大哥的代码也没通过!今天再帮我改改!!!
...全文
44 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
chenyu5188 2003-04-04
你没有理解我留给你的话。

连接对象的关闭要在最后关闭,也就是说在整个command1命令执行要结束的时候才关闭它。
回复
chenyu5188 2003-04-04

发错了。

回复
chenyu5188 2003-04-04
http://www.xygu.com/uploadImages/200312417402198504.rar
http://www.xygu.com/uploadImages/20031241740542600.rar
http://www.xygu.com/uploadImages/200312417395076828.rar
回复
bluesanke 2003-04-04
不是这个意思,后面还有好多option都要写代码的!我要是学会2个以上的就可以编多个的了!!!
回复
Option Explicit
Dim Mycn As New ADODB.Connection '数据库连接对象,用于打开数据库
Dim Myrs1 As New ADODB.Recordset '记录集对象,用于存入记录的
Private Sub Command1_Click()
Dim cnstring As String '用于存放连接字符串的
cnstring = "Provider=OraOLEDB.Oracle.1;Persist Security Info=False;User ID=dytd;PassWord=dytd;Data Source=dytd"
Mycn.Open cnstring
Mycn.CursorLocation = adUseClient
If Option1.Value = True Then
If Text1.Text = "" Then
MsgBox "请正确填写申请书编号!", vbOKOnly + vbExclamation, "信息提示"
Exit Sub
Else
Myrs1.Open "select * from DJ_CSDJ_TDDJSQS where DCT_BH='" & Trim(Text1) & "'", Mycn
If Myrs1.BOF And Myrs1.EOF Then
MsgBox "不存在申请书编号!!!", vbOKOnly + vbExclamation, "信息提示"

Text1 = ""
Text1.SetFocus
Myrs1.Close
Set Myrs1 = Nothing
Mycn.Close
Exit Sub
End If
MSHFlexGrid1.Clear
TableInit
MSHFlexGrid1.Rows = MSHFlexGrid1.Rows + 1
MSHFlexGrid1.Row = MSHFlexGrid1.Rows - 1
MSHFlexGrid1.Col = 0
MSHFlexGrid1.Text = Myrs1.Fields("DCT_BH") & ""
MSHFlexGrid1.Col = 1
.....................
Myrs1.Close
Set Myrs1 = Nothing
Else
Mycn.Close '关闭连接对象
Set Mycn = Nothing
Myrs1.Close
Set Myrs1 = Nothing
Exit Sub
Mycn.Close
End If
Mycn.Close
.............
elseif Option2.Value = True Then

......

else
......
end if
回复
相关推荐
发帖

1184

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2003-04-04 01:41
社区公告
暂无公告