datagrid更新数据库
datagrid绑定数据recodeset之后,只要datgrid内容更改,数据库相应的内容也会更改,怎样使datagrid的内容更改之后,再由用户来确定是否更新数据库?
[解决办法]
如果交update权限交给datagrid之后,用户就没法控制了
[解决办法]
不要用绑定数据库的方法,那样做在变的简单的同时也失去了不少的灵活性
[解决办法]
在 beforeupdate 之类的事件中让用户选择。
[解决办法]
不绑定直接赋值给对方却实是个不错的想法
首先将数据库的数据赋给dategrid
然后dategrid里进行相关操作
再根据条件把操作结果赋回来给数据库 举个vsflexgrid的例子
VSG1.Clear
VSG1.Cols = 6
VSG1.ColWidth(0) = 12 * 25 * 0.6
VSG1.ColWidth(1) = 12 * 25 * 3.2
VSG1.ColWidth(2) = 12 * 25 * 6
VSG1.ColWidth(3) = 12 * 25 * 3
VSG1.ColWidth(4) = 12 * 25 * 3
VSG1.ColWidth(5) = 12 * 25 * 8
VSG1.FixedRows = 1
VSG1.FixedCols = 1
VSG1.TextMatrix(0, 1) = "代 号 "
VSG1.TextMatrix(0, 2) = "出版社名称 "
VSG1.TextMatrix(0, 3) = "地 区 "
VSG1.TextMatrix(0, 4) = "邮 编 "
VSG1.TextMatrix(0, 5) = "网 址 "
VSG1.BackColorAlternate = RGB(120, 255, 110)
For i = 1 To 5
VSG1.ColAlignment(i) = flexAlignCenterCenter
Next
If VSG1.Row > 0 Then
Adodc1.RecordSource = "select * from cbsb "
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveFirst
i = 1
Do While Not Adodc1.Recordset.EOF
VSG1.TextMatrix(i, 1) = Adodc1.Recordset.Fields( "dh ")
VSG1.TextMatrix(i, 2) = Adodc1.Recordset.Fields( "mc ")
VSG1.TextMatrix(i, 3) = Adodc1.Recordset.Fields( "dq ")
VSG1.TextMatrix(i, 4) = Adodc1.Recordset.Fields( "yb ")
VSG1.TextMatrix(i, 5) = Adodc1.Recordset.Fields( "wz ")
Adodc1.Recordset.MoveNext
i = i + 1
Loop
Else
End If
End If
VSG1.Rows = Adodc1.Recordset.RecordCount + 1
VSG1.Refresh