Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating data through Datagrid? 1

Status
Not open for further replies.

jgoodman00

Programmer
Jan 23, 2001
1,510
I have an ado datagrid control (adodc1), & a datagrid control (DGrid1).

adodc1 is bound to a table [tblChannelNames].
DGrid1 is bound to adodc1.

It seems to fetch the records from the table correctly, but if I update one of the columns, the changes are not saved. Should this happen automatically, or do I need to manually force the update? James Goodman MCP
 
I've used the datagrid control once, so take this for what it's worth, but there are a couple of things to check. First, check the locktype property of your adodc1 control. Make sure it's not read only. Second, check your Allow update property for your datagrid.
 
I still cannot work it out. I used the data form wizard to create a duplicate of my form & it worked perfectly. I then made sure all settings were identical between the working & non-working form but it still didnt work. I then deleted my attempt at the datagrid, & copied the wizard created grid. It worked. Totally unsure as to what was different.

It would appear the control is bound to the db table, & when you switch row it updates the recordset. Is there a way of delaying this so it only happens when you confirm the selection (OK Button)???

Also, is there an equivilent of the Access On_Current event? I have some fields which need to be disabled when another field is true/false. In Access I would have used the On_Current event, but I dont seem to have this in VB???

James Goodman MCP
 

>Is there a way of delaying this so it only happens when you confirm the selection (OK Button)???

Check out the Adodc1_WillChangeRecord event or the grid's BeforeColUpdate or BeforeUpdate Events.

>Also, is there an equivilent of the Access On_Current event?

Yes. The DataGrid1_RowColChange (compare the lastrow bookmark to the current row.bookmark: if <> then row has changed) event or the Adodc1_MoveComplete event.

 
Cheers,

I already looked into the WillChangeRecord event, but unfortunately my grid has a number of rows (It is for an options dialog). I want to update them as a batch on press of an ok button. Surely using the WillChangeRecord event will not help me in this situation.


The other worked thanks... James Goodman MCP
 
Then use a client side cursor, disconnect the recordset from the source (Set rs.ActiveConnection = Nothing), make the changes, and once done, reconnect to the source (Set rs.ActiveConnection = myConn), and then use rs.UpdateBatch
 
Ok, very strangely it has stopped working.

I am now using the default controls built by the Data Form Wizard.

The adodc control is named datPrimaryRS.
The datagrid is named grdDataGrid

In the form load properties I have the following code:
Set Me.datPrimaryRS.Recordset.ActiveConnection = Nothing

Then under the OK button I have the following code:
Set Me.datPrimaryRS.Recordset.ActiveConnection = cnn
Me.datPrimaryRS.Recordset.UpdateBatch


Upon pressing the OK button, it successfully steps through both lines of code, & the connection is fine. However, the update is not applied...


Any ideas why this might be? James Goodman MCP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top