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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid cancel addnew

Status
Not open for further replies.

amslick

Programmer
Jan 29, 2003
6
0
0
US
Hello,

I have tried enumerable solutions posted on the web and still can't solve my problem.

I am using MS DataGrid Control 6.0 (SP5; msdatgrd.ocx) with an ADO recordset and setting the datasource in code. My database is IBM DB2 for Windows (version 7.1).

When the ADO recordset is opened with the following options,
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
Although new records save correctly, I can not seem to get the grid to successfully cancel an addnew.

If I change the lock type to adLockBatchOptimistic the addnew cancels just fine, but new records do not save.

Any suggestions would be appreciated.
 

>I have tried enumerable solutions posted on the web and still can't solve my problem.

Well, Welcome to Tek-Tips!

There are 2 or 3 possibilities, depeding on how the add new was initiated (user action by clicking the New row in the grid, or done in code, either by moving the grid row to the row +1, or by putting the recordset into the add new mode in code)
So, let's start with this:

rsado is the recordset that the data grid is bound to.

If rsado.EditMode=adEditAdd Then
rsAdo.CancelBatch
End If

If it doesn't work, then please supply more detatils.
Also, do a keyword search for Any Date on dbgAddNewPending
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top