rs.Open sql, conn 添加数据后 刷新问题
用 rs.Open sql, conn 添加数据到ACCESS数据库后用ADODC1.Refresh 刷新 datagrid1中的数据并不没刷新, 要再用ADODC1.Refresh刷新一次才被更新,,不知道是怎么回事,不知道大家是怎么刷新的具体代码
Dim sql As String
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\log.mdb;Persist Security Info=False"
sql = "INSERT INTO log (编号, 商品名称, 单价, 数量, 类别, 购买时间) VALUES ('" & List2.List(0) & "','" & List2.List(2) & "','" & List2.List(4) & "','" & List2.List(1) & "', '" & List2.List(3) & "','" & Now & "')"
rs.Open sql, conn
Adodc1.Refresh
Adodc1.Recordset.MoveLast
DataGrid1.Columns(0).Width = 500
DataGrid1.Columns(1).Width = 2100
DataGrid1.Columns(2).Width = 500
DataGrid1.Columns(3).Width = 500
DataGrid1.Columns(4).Width = 500
DataGrid1.Columns(5).Width = 1800
DataGrid1.SetFocus
StatusBar1.Panels.Item(3).Text = "共有: " & DataGrid1.ApproxCount