Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 341
  • Last Modified:

How do I update a DataGrid in VB6

I have a data grid in vb6.  I have used code to place data inthe field of my datagrid with the following code:

cboSex.text = gcol.text

However, now I want to update the field on the datagrid.  How do I update it?
0
al4629740
Asked:
al4629740
  • 4
  • 3
1 Solution
 
game-masterCommented:


good morning!

datagrid is binded on the recordset. if you have a procedure that populate your
datagrid, then just call it again to update your datagrid.

game-master
0
 
al4629740Author Commented:
What do you mean by calling it again from the attached code?
Set conn = New ADODB.Connection
 
 
        If conn.State = adStateClosed Then
        conn.Open "Provider=sqloledb;Data Source=" & ConnectionIP & ",1433;Network Library=DBMSSOCN;Initial Catalog= Attendance; User ID=sa;Password=xxxxx"
        End If
        
        esql = "select * From Attendance" & DataGridProgram & " Where CommitteeName = " & ravi & DataGridOrganization & ravi
                                             
                                             
        If Combo5.text = "By Last Name" Then
        esql = esql & " order by Text1"
        End If
                        
        If Combo5.text = "By Date Enrolled" Then
        esql = esql & " order by Text20"
        End If
        
 
 
If rec.State = adStateOpen Then
        rec.Close
End If
 
      rec.CursorType = adOpenStatic
      rec.CursorLocation = adUseClient
      rec.LockType = adLockOptimistic
      rec.Open esql, conn, , , adCmdText
 
 
      
        Set DataGrid1.DataSource = rec

Open in new window

0
 
game-masterCommented:


change your cursortype to adOpenDynamic...
make sure that your datagrid allowupdate property is
set to true.

question: does the database will be also updated when the cbosex is clicked or change in value? if yes, can u post your code for that update?

game-master
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
al4629740Author Commented:
I think that is the exact problem.   When I select the cbosex from my dropdown, I want the database to also update.  How do I do that?
0
 
game-masterCommented:

once the you have selected a value on the cbosex then moves to other
column does the value you selected appears on the cell??

if yes then just set the datagrid's alloupdate property to true. Your database
will be also updated.. Otherwise we have work to do...:-)


game-master
0
 
al4629740Author Commented:
why should it be switched to adOpenDynamic?
0
 
game-masterCommented:


Dynamic cursors consist of a set of bookmarks to the actual data in the data source. Any time the client requests a record, ADO uses the bookmark to read the current value, which means that the application always reads the latest value stored by other users.

Dynamic cursors are automatically updated when other users add or delete a record or change any record already in the Recordset.

You can always update data and perform all kinds of navigational methods on dynamic Recordsets, including using bookmarks if the provider supports them. T
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now