Extremely Urgent: Can't get databound grid to update data

I know this is simple but can't ind the answer anywhere.

bound Datagrid (ADO)  using for editing a table ... if the user modifiies the data in a cell and then closes the form the cell does not get updated in the table.

In fact the record is not updated untill they change to recordselector to a new row no matter what i do!

Help....need to fix this bug to deliver!!!!!

mnichols1202Asked:
Who is Participating?
 
pbocanegraCommented:
PLease try this in Form_Unload

If (rs.EditMode > 0) Then rs.Bookmark = rs.Bookmark
0
 
JackOfPHCommented:
try
if you are connected to a adodc data control refresh the data control by
adodc1.refresh then
datagrid1.rebind
datagrid1.refresh


0
 
JackOfPHCommented:
place this code on the after column update of the grid

Private sub Datagrid1_AfterColumnUpdate()
datagrid1.rebind
datagrid1.refresh
End sub
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.

 
leonstrykerCommented:
Are you using .NET or VB?
0
 
mnichols1202Author Commented:
Sorry Jack, Does not work!

Leon, it's VB 6

This is really weird isn't the Datagrid supposed to handle this stuff automatically? I have got to be doing something worng!

Thanks for the effort so far.

Thinking of switching to the flexgrid control.....any ideas on that?




0
 
leonstrykerCommented:
The first thing to do is to get rid of ADODC or DE. You should be populating any and all of your grids by retrieving an ADO recordset and then binding it to what ever grid you decide to use.

Leon
0
 
pbocanegraCommented:
In the "Form_Unload" write "recordset.update" where recordset is your data recordset.


0
 
mnichols1202Author Commented:

Tried binding to an ADO Recordset object - no difference

recordset.update method does nothing.  that was the first thing i tried.

The update method works but ONLY after you change to a different record in the grid
in other words you must MANUALLY cause the row the recod selector is pointing to to change. before anything i've tried to update the dataset works.

I've even tried the update method on evey RowColChange event.  Nothing.

I even change the row programatically ( really crappy solution.... but if it worked......) and that even does not cause the data to save to the table.

This can't work this way...If the datagrid really had this problem it would make it almost unuseable in any kind of edit situation....How could you know if data you changed was commited before sutting down he program, closing a window... anything......


Help Please? I;m getting kind of desperate here







0
 
leonstrykerCommented:
Second, do not use recordset.update method. What you should be doing is creating a SQL string and using that to update your data.
0
 
pbocanegraCommented:
On the line of the previous commentary:

This is a patch:

In the Form_Unload:

Private Sub Form_Unload(Cancel As Integer)
UpdateDataGridOut
End Sub

Private Sub UpdateDataGridOut
Dim sql as string
Dim x as Integer
 Public cn As New ADODB.Connection

'Suppose that the first column is the key.
sql ="Update table set "
  For x=0 to datagrid1.columns.count -1
      sql = sql & datagrid1.Colums(x).Datafield & ","
  next x
sql = mid(sql,1,len(sql)-1)
sql = sql & ")=("
  For x=0 to datagrid1.columns.count -1
      sql = sql & "'" & datagrid1.Colums(x).value & "',"
  next x
sql = mid(sql,1,len(sql)-1)
sql = sql & ") where " & datagrid1.Columns(0).datafield & "=" & datagrid1.Columns(0).Value

 With cn
     .ConnectionString = "UID=fmb;PWD=fmb;driver={Microsoft ODBC for Oracle};" _
               & "CONNECTSTRING=MERCURIO;"
     .ConnectionTimeout = 20
     .Properties("Prompt") = adPromptNever
     .CursorLocation = adUseServer
     .Open
 End With
cn.execute sql
End Sub
0
 
mnichols1202Author Commented:
Sorry, Thought I had closed this. My appologies

0
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.

All Courses

From novice to tech pro — start learning today.