接着急问!!!刚才帮忙的朋友!再看!
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, "信息提示"
Text1.SetFocus
Exit Sub
Else
Myrs1.Open "select * from DJ_CSDJ_TDDJSQS where DCT_BH='" & Trim(Text1) & "'", Mycn
MSHFlexGrid1.Clear
TableInit
MSHFlexGrid1.Rows = MSHFlexGrid1.Rows + 1
MSHFlexGrid1.Row = MSHFlexGrid1.Rows - 1
MSHFlexGrid1.Col = 0
MSHFlexGrid1.Text = Myrs1.Fields("DCT_BH") & ""
MsgBox "不存在这个进库单号码", vbOKOnly + vbExclamation, "信息提示"
Text1 = ""
Text1.SetFocus
End If
Exit Sub
End If
这是我现在正用的代码,可是只能查一遍,第2次就说实施错误,‘3705’对象打开时操作不被允许!