mshflexgrid如何联动数据库删除

发布时间:2021-12-14 14:00:21 作者:小新
来源:亿速云 阅读:149

小编给大家分享一下mshflexgrid如何联动数据库删除,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!

Mshflexgrid属性运用

MSHFlexGrid1.Row 返回当前选中的行号

MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 0)代表返回指定行的第一列的值

删除后的刷新思想

1、数据库删除后,重新进行一遍查询(不推荐,消耗性能大)

2、数据库删除后,直接在mshflexgrid上面进行删除指定行,使用语句MSHFlexGrid1.RemoveItem MSHFlexGrid1.Row

RemoveItem方法后面添加一个索引值,就可以删除指定行

文件列表:

mshflexgrid如何联动数据库删除

界面:

mshflexgrid如何联动数据库删除

源代码:

Option ExplicitDim sql As StringDim conn As New ADODB.ConnectionDim rs As ADODB.Recordset
Private Sub Command1_Click()If conn.State = 0 Then    conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Database3.mdb;Persist Security Info=False"    conn.OpenEnd If
sql = "insert into [users]([username],[password]) values('" & Text1.Text & "','" & Text2.Text & "')"
Set rs = New ADODB.Recordset
rs.Open sql, conn, adOpenKeyset, adLockBatchOptimistic'MsgBox "录入成功!"
sql = "select * from users"rs.Open sql, conn, adOpenKeyset, adLockBatchOptimistic

Set MSHFlexGrid1.DataSource = rs
'表头MSHFlexGrid1.TextMatrix(0, 0) = "唯一编号"MSHFlexGrid1.TextMatrix(0, 1) = "账号"MSHFlexGrid1.TextMatrix(0, 2) = "密码"
End Sub
Private Sub Command2_Click()If conn.State = 0 Then    conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Database3.mdb;Persist Security Info=False"    conn.OpenEnd If
Set rs = New ADODB.Recordsetsql = "select * from users"rs.Open sql, conn, adOpenKeyset, adLockBatchOptimistic
Set MSHFlexGrid1.DataSource = rs
'表头MSHFlexGrid1.TextMatrix(0, 0) = "唯一编号"MSHFlexGrid1.TextMatrix(0, 1) = "账号"MSHFlexGrid1.TextMatrix(0, 2) = "密码"End Sub
Private Sub Command3_Click()
If conn.State = 0 Then    conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Database3.mdb;Persist Security Info=False"    conn.OpenEnd If
Set rs = New ADODB.Recordset
sql = "delete from [users] where [id]=" & MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, 0)
rs.Open sql, conn, adOpenKeyset, adLockBatchOptimistic
'Call Command2_Click   '方法1
'方法2
MSHFlexGrid1.RemoveItem MSHFlexGrid1.Row
End Sub

看完了这篇文章,相信你对“mshflexgrid如何联动数据库删除”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

推荐阅读:
  1. MongoDB 删除数据库
  2. MySQL 删除数据库

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

mshflexgrid 数据库

上一篇:怎么使用IDEA

下一篇:SpreadJS 在 Angular2 中支持绑定哪些属性

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》