帮我看看这段代码,总是出问题???
If Option1.Value = True Then
txtsql = "select pro_no,pro_name,pro_address from projet where pro_no='" & Text1.text & "'"
Set mrc = New ADODB.Recordset
mrc.Open txtsql, cnn, adOpenKeyset, adLockOptimistic
If mrc.BOF = True And mrc.EOF = True Then
MsgBox "没有符合条件的记录,请重新查询!", vbOKOnly + vbExclamation, "提示"
Text1.text = ""
Exit Sub
End If
db1.DefColWidth = 1100
data1.RecordSource = txtsql '未发现数据源名称并且未制定默认驱动器
'data1.Refresh
Set db1.DataSource = data1
db1.Refresh
' Dim i As Integer
' Dim totalwidth As Integer
Dim col1(28) As Column
For i = 1 To 28
Set col1(i) = db1.Columns(i - 1) ‘下标越界 i=3
Next
col1(1).Caption = "工程编码"
col1(2).Caption = "工程名称"
col1(3).Caption = "工程地址"
Exit Sub
End If
End Sub