Datagrid not supported Refresh after add, delete, ... ?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Datagrid not supported Refresh after add, delete, ... ?

  1. #1
    Join Date
    Sep 2007
    Posts
    183

    Datagrid not supported Refresh after add, delete, ... ?

    suppose I have database access:
    Dim Conn As ADODB.Connection

    Set RS = Nothing
    Set RS = New Recordset

    Set Conn = New ADODB.Connection
    Conn.Open ConnectionStringHere

    RS.Open "SELECT Fields " & _
    "FROM Table WHERE Whatever = ?"
    Conn, adOpenStatic, adLockOptimistic
    Datagrid.DataSource = RS

    when you perform the insert, delete, add new data, datagrid refresh the data can not although I have to use appearance Datagrid.Refresh new data is entered but does not appear, check the data in have access but do not anticipate new output datagrid except close all open programs to emerging new data on the grid, the operations insert, delete, add items via the command. Execute (strSQL ), why not refresh the datagrid? and how to fix?

  2. #2
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,722

    Re: Datagrid not supported Refresh after add, delete, ... ?

    You have to refresh the Recordset, not the DataGrid.
    Keep the recordset stored in a global variable (or private to a form if your code is all in a form)
    Code:
      Public/Pivate rsGrid as ADODB.Recordset
    ...
      'your open rs
      rs.open sql$, Conn, adOpenStatic, adLockOptimistic
      Set rsGrid = rs
      Set DataGrid.DataSource = rs
    After doing an update, insert or delete you go
    Code:
      rsGrid.Requery
      Set DataGrid.DataSource = rsGrid

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center