标题:[求助]MSHflexgrid控件的数据源如何改变
只看楼主
peswe
Rank: 1
等 级:新手上路
帖 子:197
专家分:0
注 册:2006-11-22
 问题点数:0 回复次数:4 
[求助]MSHflexgrid控件的数据源如何改变

如题!~
以下是代码!~

Private Sub Command1_Click()
Dim rst As New ADODB.Recordset
Dim StrSql As String
Dim ArrIndex As Variant
ArrIndex = Array("student_id", "student_name", "sex", "nathionality", "familiy_place", "class_id", "pro_id")
If Option1.Value = True Then
StrSql = "select * from students where " & ArrIndex(Combo1.ListIndex) & "='" & Text1.Text & "'"
Set rst = QueryExt(StrSql)
ElseIf Option2.Value = True Then
StrSql = "select * from students where " & ArrIndex(Combo1.ListIndex) & "='" & Text1.Text & "' and " & ArrIndex(Combo2.ListIndex) & "='" & Text2.Text & "'"
Set rst = QueryExt(StrSql)
End If
If rst.EOF = True Then
MsgBox "没有满足条件的学生,请确认输入的查询内容正确!~"
Text1.SetFocus
Exit Sub
End If
Set MSH1.DataSource = rst.DataSource '在这里负值数据源就会出错,可是在下面却可以!~
MSH1.Refresh
End Sub

Private Sub Form_Load()
Dim rst As New ADODB.Recordset
Dim StrSql As String
StrSql = "select * from students"
Set rst = QueryExt(StrSql)
Set MSH1.DataSource = rst.DataSource '在这里也是负值,但不会出错!~
MSH1.Refresh
Set rst = Nothing
Combo1.AddItem "学号"
Combo1.AddItem "姓名"
Combo1.AddItem "性别"
Combo1.AddItem "民族"
Combo1.AddItem "籍贯"
Combo1.AddItem "所在学院"
Combo1.AddItem "所在专业"
Combo2.AddItem "学号"
Combo2.AddItem "姓名"
Combo2.AddItem "性别"
Combo2.AddItem "民族"
Combo2.AddItem "籍贯"
Combo2.AddItem "所在学院"
Combo2.AddItem "所在专业"
Combo1.ListIndex = 0
Combo2.ListIndex = 0
Text1.Text = ""
Text2.Text = ""
Combo1.Enabled = False
Combo2.Enabled = False
Text1.Enabled = False
Text2.Enabled = False
End Sub

Private Sub Option1_Click()
If Option1.Value = True Then
Combo1.Enabled = True
Text1.Enabled = True
Combo2.Enabled = False
Text2.Enabled = False
Text1.SetFocus
Else
Combo1.Enabled = False
Text1.Enabled = False
End If
End Sub

Private Sub Option2_Click()
If Option2.Value = True Then
Text1.SetFocus
Combo2.Enabled = True
Text2.Enabled = True
Else
Combo2.Enabled = False
Text2.Enabled = False
End If
End Sub

搜索更多相关主题的帖子: 数据源 MSHflexgrid 控件 rst 
2007-10-25 10:58
peswe
Rank: 1
等 级:新手上路
帖 子:197
专家分:0
注 册:2006-11-22
得分:0 
不是把,还没人回答!~
是不是看代码好长啊,其实可以不看其他代码的,只看红色部分就可以了,其他代码只是给个参照环境!~
高手千万指点下!~

C斗士~~~fighting!!!!
2007-10-26 11:02
simpson
Rank: 3Rank: 3
等 级:论坛游民
威 望:7
帖 子:863
专家分:17
注 册:2006-11-16
得分:0 
If rst.EOF = True and rst.BOF = true Then
MsgBox "没有满足条件的学生,请确认输入的查询内容正确!~"
Text1.SetFocus
Exit Sub
End If

全国最大的 Java专业电子书免费分享[url]http:///in.asp?id=xrmao[/url]
2007-10-26 12:54
peswe
Rank: 1
等 级:新手上路
帖 子:197
专家分:0
注 册:2006-11-22
得分:0 
谢谢你的意见,我改了,可好像不是这里的问题,他的错误提示是:
“Unable to access data.DataSource settings may be incorrect or the DataSource functionality may be limited.See Help for more information.”
可是在MSDN中找又找不到!~

望再给点意见!~

C斗士~~~fighting!!!!
2007-10-26 15:51
peswe
Rank: 1
等 级:新手上路
帖 子:197
专家分:0
注 册:2006-11-22
得分:0 

问题已经解决!~
谢谢各位的光临!~ ^_^


C斗士~~~fighting!!!!
2007-10-27 13:19



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-180632-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.075894 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved