第3次接着问!今天没解决!明天还问!
Option Explicit
Dim Mycn As New ADODB.Connection '数据库连接对象,用于打开数据库
Dim Myrs1 As New ADODB.Recordset '记录集对象,用于存入记录的
Dim Myrs2 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
End Sub
改成这样测试通过!
但是新问题有来了
在后面加
If Option2.Value = True Then
If Text2.Text = "" Then
MsgBox "请正确填写土地使用者!", vbOKOnly + vbExclamation, "信息提示"
Exit Sub
Else
Myrs1.Open "select * from DJ_CSDJ_TDDJSQS where DCT_TDSYZ='" & Trim(Text2) & "'", Mycn
If Myrs1.BOF And Myrs1.EOF Then
MsgBox "不存在土地使用者!!!", vbOKOnly + vbExclamation, "信息提示"
Text2 = ""
Text2.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
End Sub
有问题呢????!!!