帮我看看这段代码,总是出问题???

hope_mx 2004-04-27 12:06:54
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
...全文
43 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
northwolves 2004-04-27
  • 打赏
  • 举报
回复
可以将DATAGRID 绑定到 ADODC 控件,不过建议你写代码解决。
2004chenlong 2004-04-27
  • 打赏
  • 举报
回复
见意只用ADODB就行了。DATA已经过时了。
饮水需思源 2004-04-27
  • 打赏
  • 举报
回复
'改用mshflexgrid控件:

If Option1.Value = True Then
txtsql = "select pro_no as 工程编码,pro_name as 工程名称,pro_address as 工程地址 from projet where pro_no='" & Text1.text & "'"
Set mrc = New ADODB.Recordset
if mrc.state=adstateopen then mrc.close
mrc.Open txtsql, cnn, adOpenKeyset,adlockreadonly
If mrc.recordcount=0 Then
MsgBox "没有符合条件的记录,请重新查询!", vbOKOnly + vbExclamation, "提示"
Text1.text = ""
mrc.close
Exit Sub
End If

set mshflexgrid.datasource=mrc '绑定到mshflexgrid控件
mrc.close
set mrc=nothing
End Sub
haipingma 2004-04-27
  • 打赏
  • 举报
回复
Data1.DatabaseName = "c:\AccessTemp.mdb"
沒有指定數据源,況且你已經用了ado對象,還用data做什么
data控件适合access97
ukyoxh 2004-04-27
  • 打赏
  • 举报
回复
你既然使用了adodb为什么还要使用data控件啊

不懂

反正我没有使用过data控件来绑定

ukyoxh 2004-04-27
  • 打赏
  • 举报
回复
你既然使用了adodb为什么还要使用data控件啊

不懂

反正我没有使用过data控件来绑定

1,451

社区成员

发帖
与我相关
我的任务
社区描述
VB 控件
社区管理员
  • 控件
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧