日期:2014-05-16 浏览次数:20640 次
在做机房收费系统的时候,遇到了这个问题“删除MSHFlexGrid选中行及其sql数据库中对应记录”,
我通过查找资料,进行了整理,在此和大家切磋一下。下面是我的代码:
Option Explicit
Dim NowRow As Integer
Private Sub MSHFlexGrid1_MouseDown(ButtonAs Integer, Shift As Integer, x As Single, y As Single)
With MSHFlexGrid1
.Row = .MouseRow
NowRow = .Row
.Col = 0
.ColSel = .Cols - 1
End With
End Sub
Private Sub MSHFlexGrid1_MouseUp(Button AsInteger, Shift As Integer, x As Single, y As Single)
With MSHFlexGrid1
.RowSel = NowRow
.ColSel = .Cols - 1
End With
EndSub
Private Sub cmdDelete_Click()
Dim rstMrc As ADODB.Recordset
Dim strSQL As String
Dim strMsgtextAs String
strSQL ="delete from User_Info where UserID= ' " & Trim(MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row,0)) & " ' "
Set rstMrc =ExecuteSQL(strSQL, strMsgtext)
MSHFlexGrid1.RemoveItemMSHFlexGrid1.Row
End sub