| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 765 人关注过本帖, 1 人收藏
标题:求助]MSHFlexGrid控件的问题
只看楼主 加入收藏
zsl5566
Rank: 1
来 自:泉州
等 级:新手上路
帖 子:163
专家分:0
注 册:2006-12-12
收藏(1)
 问题点数:0 回复次数:5 
求助]MSHFlexGrid控件的问题

我做了一个学生管理系统,调试时他提示 424实时错误,要求对象
代码如下:

Dim conn As New ADODB.Connection
Dim connectionstring As String
Dim jfm As New ADODB.Recordset
Dim xsjl As New ADODB.Connection
Dim SQL As String

Private Sub Comcx_Click()
TXTCX1.Text = Trim(TXTCX1.Text)
TXTCX2.Text = Trim(TXTCX2.Text)
If TXTCX1.Text <> "" And TXTCX2.Text <> "" Then
SQL = "select * from studeng where " & Combo1.Text & " like '" & TXTCX1.Text & "' and " & Combo2.Text & " like '" & TXTCX2.Text & "'"
GoTo cont1
End If
If TXTCX1.Text <> "" Then
SQL = "select * from student where " & Combo1.Text & " like '" & TXTCX1.Text & "'"
GoTo cont1
End If
If TXTCX2.Text <> "" Then
SQL = "select * from student where " & Combo2.Text & " like '" & TXTCX2.Text & "'"
GoTo cont1
End If
SQL = "select * from student"
cont1:
Set jfm = conn.Execute(SQL)
Call Data_Display
End Sub

Private Sub ComDEL_Click()
If TXTXH.Text = "" Then
MsgBox "学号不能为空!", vbOKOnly, "information"
TXTXH.SetFocus
Exit Sub
End If
SQL = "delete from student where 学号='" & TXTXH.Text & "'"
conn.Execute (SQL)
Call Data_Display
Call Clear
End Sub

Private Sub Comexit_Click()
Unload Me

End Sub

Private Sub Comsafe_Click()
Dim Msg As String
Dim Sid As Integer
Dim jfm As New ADODB.Recordset
Dim Cj As New ADODB.Recordset
Dim SQL As String

'Dim xsjl As String
'检查是否存在该学生生数据
If TXTXH.Text = "" Then
MsgBox "学号不能为空!", vbOKOnly, "information"
TXTXH.SetFocus
Exit Sub
End If
If IsNumeric(TXTYW.Text) = False Then
MsgBox "语文成绩为数字,请重新输入!", vbOKOnly, "information"
TXTYW.SetFocus
Exit Sub
End If
If IsNumeric(TXTSX.Text) = False Then
MsgBox "数学成绩为数字,请重新输入!", vbOKOnly, "information"
TXTSX.SetFocus
Exit Sub
End If
If IsNumeric(TXTEN.Text) = False Then
MsgBox "英语成绩为数字,请重新输入!", vbOKOnly, "information"
TxtYy.SetFocus
Exit Sub
End If

SQL = "select 学号 from student where 学号='" & TXTXH.Text & "'"
Set xsjl = conn.Execute(SQL)
If xsjl.BOF And xsjl.EOF Then
SQL = "insert into student (学号,姓名,性别,班级,联系电话,语文成绩,数学成绩,英语成绩) "
SQL = SQL & "values ('" & TXTXH.Text & "','" & TXTXM.Text & "','" & TXTXB.Text & "','" & TXTBJ.Text & "','" & TXTDH.Text & "','" & TXTYW.Text & "','" & TXTSX.Text & "','" & TXTEN.Text & "')"
conn.Execute (SQL)

MsgBox "存盘成功!", vbOKOnly, "information"
Else
SQL = "update student set 姓名='" & TXTXM.Text & "',性别='" & TXTXB.Text & "',班级='" & TXTBJ.Text & "',联系电话='" & TXTDH.Text & "',语文成绩='" & TXTYW.Text & "',数学成绩='" & TXTSX.Text & "',英语成绩='" & TXTEN.Text & "' where 学号='" & TXTXH.Text & "'"
conn.Execute (SQL)
MsgBox "修改成功!", vbOKOnly, "information"
End If

Call Data_Display
End Sub

Private Sub Form_Load()
Call Clear
Call MSFG_Clear
conn.connectionstring = "Provider=SQLOLEDB.1;Persist Security Info=False;Password=sa;user ID=sa;Initial Catalog=student;Data Source=hi"
conn.Open
SQL = "select * from student"
Set jfm = conn.Execute(SQL)
Call Data_Display
End Sub
Private Sub MSFG_Clear()
MSFlexGrid1.ColWidth(0) = 800 (出错的地方)
MSFlexGrid1.ColAlignment(0) = flexAlignCenterCenter
MSFlexGrid1.ColWidth(1) = 800
MSFlexGrid1.ColWidth(2) = 1400
MSFlexGrid1.ColWidth(3) = 800
MSFlexGrid1.ColWidth(4) = 1300
MSFlexGrid1.ColWidth(5) = 1200
MSFlexGrid1.ColWidth(6) = 1200
MSFlexGrid1.ColWidth(7) = 1200
MSFlexGrid1.ColWidth(8) = 1200
MSFlexGrid1.Rows = 1
End Sub
Private Sub Clear()
TXTXH.Text = ""
TXTXM.Text = ""
TXTXB.Text = ""
TXTBJ.Text = ""
TXTDH.Text = ""
TXTYW.Text = ""
TXTSX.Text = ""
TXTEN.Text = ""
TXTCX1.Text = ""
Combo1.Text = "学号"
TXTCX2.Text = ""
Combo2.Text = "姓名"
End Sub

Private Sub Data_Display()
Dim i As Integer

MSFlexGrid1.Rows = 1 '清空表
If (Not jfm.BOF) And (Not jfm.EOF) Then
i = 0
jfm.MoveFirst
Do While Not jfm.EOF
MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
i = i + 1
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 0) = i
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 1) = Trim(jfm("学号"))
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 2) = Trim(jfm("姓名"))
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 3) = Trim(jfm("性别"))
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 4) = Trim(jfm("班级"))
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 5) = Trim(jfm("联系电话"))
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 6) = Trim(jfm("语文成绩"))
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 7) = Trim(jfm("数学成绩"))
MSFlexGrid1.TextMatrix(MSFlexGrid1.Rows - 1, 4) = Trim(jfm("英语成绩"))
jfm.MoveNext
Loop

End If
End Sub
Private Sub MSFlexGrid1_Click()
TXTXH.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 1)
TXTXM.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 2)
TXTXB.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 3)
TXTBJ.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 4)
TXTDH.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 5)
TXTYW.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 6)
TXTSX.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 7)
TXTEN.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.Row, 8)

End Sub
Private Sub MSFlexGrid1_RowColChange()
Call MSFlexGrid1_Click
End Sub
那位兄弟帮帮看,问题该怎么解决..我把原代码也上传了!请帮帮忙

[此贴子已经被作者于2006-12-31 10:38:11编辑过]

搜索更多相关主题的帖子: SQL MSHFlexGrid 控件 Dim 
2006-12-31 09:56
purana
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:广东-广州
等 级:版主
威 望:66
帖 子:6039
专家分:0
注 册:2005-6-17
收藏
得分:0 
MSFlexGrid1
你有这个控件吗?

我的msn: myfend@
2006-12-31 10:06
zsl5566
Rank: 1
来 自:泉州
等 级:新手上路
帖 子:163
专家分:0
注 册:2006-12-12
收藏
得分:0 

有啊。


不要给准备要做的事寻找失败的理由~~
2006-12-31 10:07
purana
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:广东-广州
等 级:版主
威 望:66
帖 子:6039
专家分:0
注 册:2005-6-17
收藏
得分:0 
MSFlexGrid1.ColWidth(0) = 5000
我试了.好像没问题的哦.

我的msn: myfend@
2006-12-31 10:11
zsl5566
Rank: 1
来 自:泉州
等 级:新手上路
帖 子:163
专家分:0
注 册:2006-12-12
收藏
得分:0 
你QQ多少啊?我把文件发给你,你帮我看看,好吗??我QQ是181385527

不要给准备要做的事寻找失败的理由~~
2006-12-31 10:14
zsl5566
Rank: 1
来 自:泉州
等 级:新手上路
帖 子:163
专家分:0
注 册:2006-12-12
收藏
得分:0 

谢谢斑竹~!原来是名称错了`!~SORRY~!再次感谢!~

新年快乐~!~论坛的朋友没`!


不要给准备要做的事寻找失败的理由~~
2006-12-31 12:22
快速回复:求助]MSHFlexGrid控件的问题
数据加载中...
 
   



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

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