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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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

JackOfPHCommented:
try
if you are connected to a adodc data control refresh the data control by
adodc1.refresh then
datagrid1.rebind
datagrid1.refresh


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

Private sub Datagrid1_AfterColumnUpdate()
datagrid1.rebind
datagrid1.refresh
End sub
leonstrykerCommented:
Are you using .NET or VB?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

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?




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
pbocanegraCommented:
In the "Form_Unload" write "recordset.update" where recordset is your data recordset.


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







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.
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
pbocanegraCommented:
PLease try this in Form_Unload

If (rs.EditMode > 0) Then rs.Bookmark = rs.Bookmark

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
mnichols1202Author Commented:
Sorry, Thought I had closed this. My appologies

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.