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?
al4629740Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.