MSHFlexGrid控件刷新问题
我用这个MSHFlexGrid来连接数据库,但是不能刷新,代码如下:
With MSHFlexGrid1
.Row = .Row + 1
.Refresh
.Row = .Row - 1
.Text = Text1(1).Text
.Col = 3
.Text = Text1(0).Text
.Col = 4
.Text = Text1(2).Text
.Col = 5
.Text = Comb1.Text
.Col = 6
.Text = Text1(3).Text
.Col = 7
.Text = DTPk1.Value
.Col = 8
.Text = Text1(4).Text
.Refresh
End With
buf = MsgBox("确定添加记录?", 49, "提示")
' buf1 = MsgBox("添加记录成功!", 49, "提示")
If buf = 1 Then
Call openRs("insert into revenue (R_Name,R_money,R_Handling,R_Manner,R_Place,R_Time,R_Note) values ('" & Text1(1).Text & "','" & Text1(0).Text _
& "','" & Text1(2).Text & "','" & Comb1.Text & "','" & Text1(3).Text & "','" & DTPk1.Value & "','" & Text1(4).Text & "')") '添加记录
MSHFlexGrid1.Refresh // 这可以不要,因为没有影响
End If
END SUB
我看下了一个,可以刷新,但是我放在我那用,就不能刷新,请高手们指教
下面这可以刷新的,但是放在我那就不行:
Dim cn As New ADODB.Connection
Dim sql As String, i As Long
With MSHFlexGrid1
.Rows = .Rows + 1
.Refresh
.Row = .Rows - 1
.Col = 1
.Text = Text1(0).Text
.Col = 2
.Text = Text1(1).Text
.Col = 3
.Text = Text1(2).Text
.Refresh
End With
cn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=zzgjcj;Data Source=."
sql = "insert into stmp (id,ss,aa) values (" & Text1(0).Text _
& ",'" & Text1(1).Text & "','" & Text1(2).Text & "')"
cn.Execute sql, i
If i > 0 Then MsgBox "添加成功"
cn.Close
Set cn = Nothing
第一个是我按照这种方法写,但是怎么做的不能刷新,
[解决办法]
插入数据后,要重新打开MSHFlexGrid1绑定的数据源(即MSHFlexGrid1的数据源要重新查询)。
[解决办法]