Problem w/SqlAdapter.Update on Child Tables

M

Mark Olbert

I'm getting a "null object" exception when I try to update a dataset where a new master and a new
child record have been created. In other words, Master has a new record and Child has a new record
whose foreign key is the Master record's autosequence idnumber.

If I create just a new Master record, call SqlAdapter.Update(), and then create a new Child record
for the Master record and call SqlAdapter.Update() no exception is thrown.

Both Master and Child have their autonumber idfields set to seeds of -1 and increments of -1 (i.e.,
so newly-created records are assigned unique IDs that "grow" down). I did this because I was running
into some other problems when creating new master/child tuples.

The Update, Delete and Accept/Reject rules for the Master/Child relation are set to Cascade.

Does ADO.NET not support the simultaneous creation of new Master/Child tuples? Or must I
programmatically control the sequence of when the Master and Child adapters call Update()?

Thanx in advance for any help or advice.

- Mark
 
M

Mark Olbert

Some additional info: I can avoid the problem I outlined in my earlier post by controlling the
sequence with which the SqlAdapter.Update() methods get called.

When new Master/Child tuples are added, if I call Update() on the Child side first, followed by the
Master, no null object exception is thrown.

What's confusing the heck out of me is that I've previously run into problems where the Master side
has to be Updated() first.

So...could one of the experts here weigh in on "best practices" for adding/changing/deleting
Master/Child tuples and how those should be pushed back to a SqlServer database?

- Mark
 
J

Joe Fallon

Read ADO.Net by David Sceppa.
It is an excellent book.

You have to process the Parent records first then the Child records.

'insert New records for Item table on Server
Dim NewItemRecords() As DataRow =
ds.Tables("dtItem").Select(Nothing, Nothing, DataViewRowState.Added)
NumNewItems = NewItemRecords.GetUpperBound(0) + 1
da_Item.Update(NewItemRecords)

'insert New records for Itemcur table on Server
Dim NewItemcurRecords() As DataRow =
ds.Tables("dtItemcur").Select(Nothing, Nothing, DataViewRowState.Added)
NumNewItemcurs = NewItemcurRecords.GetUpperBound(0) + 1
da_Itemcur.Update(NewItemcurRecords)
 
D

Duray AKAR

If you have the same relations defined in SQL server you
wont be able to insert child records first...

I have this master child relations and with the default
values for update delete and accept reject , i dont get
any problems with first updating the master, and then the
child...

but it gets rather complicated if you are handling the
rowchanging , column changing events and doing other
validations... :)

hope it helps...
-----Original Message-----
Some additional info: I can avoid the problem I outlined
in my earlier post by controlling the
sequence with which the SqlAdapter.Update() methods get called.

When new Master/Child tuples are added, if I call Update
() on the Child side first, followed by the
Master, no null object exception is thrown.

What's confusing the heck out of me is that I've
previously run into problems where the Master side
has to be Updated() first.

So...could one of the experts here weigh in on "best
practices" for adding/changing/deleting
 
M

Mark Olbert

Thanx both of you for advice. But, I'm REALLY starting to get frustrated -- and pissed off! -- at
Microsoft for the shoddy way in which ADO.NET and SqlServer (at least) work together. Or, more
accurately, DON'T work together.

I tried implementing the tactic of "first add the master, then add the detail" for new tuples. Well,
that blew up with "sorry, data integrity constraints would result in pending detail records being
stranded". Which I presume is because when a new master record is added, the autosequence idnumber
gets changed based on the update and it will, of course, be a different value than the one the
pending detail record is based on.

So then I figured, okay, turn off EnforceConstraints, do the updates, and then turn
EnforceConstraints back on. So sorry, that blew up too, with some less helpful error message (i.e.,
"hey something went wrong in talking to SQL server"; god, I detest error messages that tell you
So I'm still stuck. And I cannot BELIEVE that something as common and necessary as updating a
master/detail structure is so badly handled -- it should be handled without any special intervention
at all!!!

Okay, enough tirade. I just had such hopes based on my initial experience with .NET that Microsoft
had finally gotten away from the philosophy of "our first few releases are crap, but stick with us,
we'll get you there eventually". Apparently that's not the case, based on all the broken databinding
code I've encountered over the last few weeks.

Anyone have any other ideas on how to do master/detail updates? Or what might be causing these
crashes? Or should I just tell my client it's impossible to build a reliable database project in
..NET?

- Mark
 
J

Joe Fallon

This exact case is explained in detail in the book I recommended earlier!
It is tricky. There is no way you are going to get the answer without
knowing this trick.

You have discovered the issues through trial and error.
The solution is to set up cascade update in your dataset so that when the
new Identity value is returned from the database you update the master table
and cascade the change to the child.
You have to trap the RowUpdated event and then post the new identity value.

For SQL Server, there is a way to send 2 statements separated by a
semi-colon.
The first is your Parent update statement the second is Select
@@Scope_Identity.
(I am not 100% sure about this though.) (See below for the method I really
use.)

For Access and Oracle (and SQL Server if you don't use multiple statements):
You have to trap the RowUpdated event and then post the new identity value.

================================================================
In my update method I have some code like this:

'handle the RowUpdated event to get the Identity value back from
SQL Server
'w/o the real Identity value, the child records won't be added to
SQL Server.
AddHandler da_Eimhdr.RowUpdated, AddressOf da_Handle_RowUpdated

'parent table
da_Eimhdr.Update(NewEimhdrRecords)

'child table
da_Eimln.Update(NewEimlnRecords)
================================================================
'this is how to handle the insert of each row:

Private Sub da_Handle_RowUpdated(ByVal sender As Object, ByVal e As
SqlRowUpdatedEventArgs)
If e.Status = UpdateStatus.Continue And e.StatementType =
StatementType.Insert Then
e.Row("eimkey") = GetIdentity(e.Command.Connection)
e.Row.AcceptChanges()

'use this if you do not want to AcceptChanges for each row.
'e.Status = UpdateStatus.SkipCurrentRow
End If
End Sub
================================================================
Private Function GetIdentity(ByRef cnn As SqlConnection) As Integer
Dim oCmd As New SqlCommand("SELECT @@IDENTITY", cnn)
Dim x As Object = oCmd.ExecuteScalar()
Return CInt(x)
End Function
================================================================





For Oracle - I use this code:
================================================================

Private Sub da_Handle_OracleRowUpdated(ByVal sender As Object, ByVal e As
OracleRowUpdatedEventArgs)
If e.Status = UpdateStatus.Continue And e.StatementType =
StatementType.Insert Then
e.Row("eimkey") = GetOracleSequence(e.Command.Connection)
e.Row.AcceptChanges()

'use this if you do not want to AcceptChanges for each row.
'e.Status = UpdateStatus.SkipCurrentRow
End If
End Sub

Private Function GetOracleSequence(ByRef cnn As OracleConnection) As
Integer
Dim oCmd As New OracleCommand("SELECT SEQ_EIMHDR_EIMKEY.CURRVAL FROM
DUAL", cnn)
Dim x As Object = oCmd.ExecuteScalar()
Return CInt(x)
End Function
================================================================

--
Joe Fallon




Mark Olbert said:
Thanx both of you for advice. But, I'm REALLY starting to get
frustrated -- and pissed off! -- at
Microsoft for the shoddy way in which ADO.NET and SqlServer (at least) work together. Or, more
accurately, DON'T work together.

I tried implementing the tactic of "first add the master, then add the detail" for new tuples. Well,
that blew up with "sorry, data integrity constraints would result in pending detail records being
stranded". Which I presume is because when a new master record is added, the autosequence idnumber
gets changed based on the update and it will, of course, be a different value than the one the
pending detail record is based on.

So then I figured, okay, turn off EnforceConstraints, do the updates, and then turn
EnforceConstraints back on. So sorry, that blew up too, with some less helpful error message (i.e.,
"hey something went wrong in talking to SQL server"; god, I detest error messages that tell you
SOMETHING ABOUT WHAT CAUSED IT).
So I'm still stuck. And I cannot BELIEVE that something as common and necessary as updating a
master/detail structure is so badly handled -- it should be handled
without any special intervention
 
D

David Sceppa

Mark,

This is a commonly asked question on the newsgroups. Here's
a response I've posted in the past that has addressed most
questions. Please respond if it does not help you handle the
scenario.

Leave the AcceptRejectRule property on the
ForeignKeyConstraint object as None, the default. If you set the
property to Cascade, then submitting a pending insert on a child
row will set the RowState on both the parent and related child
rows to Unchanged and you won't be able to use a DataAdapter to
submit the pending children to the database.

I hope this information proves helpful.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2003 Microsoft Corporation. All rights reserved.




This is a fairly common scenario that ADO.NET handles much
better than any of its predecessors. It will seem complex at
first, but once you've handled the scenario once, it will
hopefully feel more intuitive.


1.) How do I keep pending parent and children in synch?

Set the ADO.NET DataColumn's AutoIncrement property to True
and ADO.NET will generate placeholder values for new rows. The
new values depend on the AutoIncrementStep, AutoIncrementSeed,
and the last value used in the DataTable. I recommend setting
AutoIncrementSeed and AutoIncrementStep to -1. These settings
will generate placeholder values of -1, -2, -3, … There are two
benefits to this approach. The values won't conflict with any
that actually exist in the database. The user will not
misinterpret the placeholder value as an actual value from the
database.

As you add the parent rows and ADO.NET generates placeholder
values, use those placeholder values for your pending child rows.
The DataRelation object will make it easy to go from parent to
child and back, either in code or in bound controls.


2.) How do I fetch the new key values for the parent rows as I
submit them?

If you're using SQL Server, this process is actually very
simple. If you were writing your own queries, you would execute
an "INSERT INTO…" query to insert the new row and then execute a
"SELECT SCOPE_IDENTITY()" query to retrieve the last identity
value generated on that connection.

The DataAdapter submits changes via its InsertCommand
property. You can append ";SELECT @@IDENTITY AS MyIDColumn" to
the end of the "INSERT INTO..." query. (SQL 2000 users should
use "SELECT SCOPE_IDENTITY()..." instead of "SELECT @@IDENTITY".
See SQL Server Books OnLine for more information on why.) If
you're building your DataAdapters via Visual Studio .NET's
DataAdapter Configuration Wizard, the wizard will do this for you
automatically.

If you're writing your code by hand, make sure the
InsertCommand's UpdatedRowSource property is set to Both (the
default) or FirstReturnedRecord. This property controls whether
the DataAdapter will fetch the row returned by the query and
apply that data to the DataRow object.

This functionality is possible because SQL Server allows you
to execute a batch of queries that returns rows. However, not
all databases support this feature.

If you're working with an Access database, you'll need to go
a slightly different route. Trap for the DataAdapter's
RowUpdated event and use code to check for a successful insert.
Execute the "SELECT @@IDENTITY" query using a Command object and
assign the value returned by the query to the appropriate column
and call the DataRow object's AcceptChanges method. Your code
will look something like this:

Visual Basic .NET:
Dim da As New OleDbDataAdapter(strSQL, strConn)
Dim cn As OleDbConnection = da.SelectCommand.Connection
Dim cmdGetIdentity As New OleDbCommand("SELECT @@IDENTITY", cn)
AddHandler da.RowUpdated, AddressOf HandleRowUpdated
Dim tbl As DataTable = CreateMyDataTable()
da.Fill(tbl)
...
da.Update(tbl)

Private Sub HandleRowUpdated(ByVal sender As Object, _
ByVal e As
OleDbRowUpdatedEventArgs)
If e.Status = UpdateStatus.Continue AndAlso _
e.StatementType = StatementType.Insert Then
e.Row("OrderID") =
Int32.Parse(cmdGetIdentity.ExecuteScalar().ToString())
e.Row.AcceptChanges()
End If
End Sub

Visual C# .NET:
OleDbDataAdapter da = new OleDbDataAdapter(strSQL, strConn);
OleDbConnection cn = da.SelectCommand.Connection;
OleDbCommand cmdGetIdentity = new OleDbCommand("SELECT
@@IDENTITY", cn);
da.RowUpdated += new
OleDbRowUpdatedEventHandler(HandleRowUpdated);
DataTable tbl = CreateMyDataTable();
da.Fill(tbl);
...
da.Update(tbl);

private void HandleRowUpdated(object sender,
OleDbRowUpdatedEventArgs e)
{
if ((e.Status == UpdateStatus.Continue) &&
((e.StatementType == StatementType.Insert))
{
e.Row["OrderID"] =
Int32.Parse(cmdGetIdentity.ExecuteScalar().ToString());
e.Row.AcceptChanges();
}
}

You can use similar techniques to retrieve server-generated
values from other databases as well. MySQL developers can use
the "LAST_INSERT_ID()" instead of "@@IDENTITY" to retrieve the
last auto-increment value generated. Oracle developers can use
"SELECT SequenceName.CURRVAL FROM DUAL" to retrieve the last
value generated for a sequence on the connection.


3.) How do I cascade the new key values to the child rows before
I submit them?

This is the simplest part of the process. When you create a
DataRelation object, ADO.NET will add a ForeignKeyConstraint
object to make sure that child rows match up to a parent row.
The ForeignKeyConstraint object exposes a UpdateRule property.
If this property is set to Cascade (the default), ADO.NET will
automatically cascade changes made to the parent down to the
associated child rows.

So, if you have a DataRelation set up between the DataTables
based on the auto-increment column, and you've set the parent
DataAdapter's InsertCommand to fetch the new auto-increment
values from the database, ADO.NET will cascade the new values
down to the associated child rows automatically.


I hope this information proves helpful. For more
information, see Chapter 11 of Microsoft ADO.NET, available
through Microsoft Press.
 
M

Mark Olbert

Joe,

Thanx for the code example again, and I will go buy that book.

But...all that to update a master/detail relationship??? Somebody up in Redmond is NOT paying
attention to how developers actually try to use the s**t they actually ship.

- Mark
 
M

Mark Olbert

David,

No, it doesn't solve the problem. The line:

theSqlAdapter.Update(theDataSet);

blows up with a NullReferenceException (I don't have any other detail because apparently the
interface to SqlServer is too braindead to pass any meaningful information along).

Is it even possible to update a new master/detail tuple in ADO.NET? Or do you have to create and
save the master record first, then create the detail record?

- Mark
 
D

David Sceppa

Mark,

I haven't seen anyone run into that exception with that type
of a scenario before. If you could post an isolated repro
scenario, I could try to reproduce the problem here. Or I could
post isolated code that handles the scenario.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2003 Microsoft Corporation. All rights reserved.
 
M

Mark Olbert

That's a different problem!

Got any more hot tips on the master/detail problem, then?

- Mark
 
M

Mark Olbert

David,

First off, allow me to be the 8,768th person to thank you for writing a clear and comprehensive book
on ADO.NET :) I just bought it, and it's already been very helpful.

I >>think<< I've solved my master/detail update problem (although I've thought that before) by using
Select() and RowState to handle separately deletions, additions and modifications, handling the
master tables first for additions and modifications and last for deletions. Although I still think
ADO.NET should be handling something like this automagically when it "knows" about the relations
between DataTables.

However, there seems to be a quirk in the DataGrid I use to bind to the detail table on my form. If
I create a new master/detail tuple, and move off of it (i.e., to a different master record) then the
master/detail update mechanism I've created works fine.

But if I do an SqlAdapter.Update() on the new master/detail tuple while it is the current record on
the form, the update against SqlServer appears to work, but the detail DataGrid doesn't "see" the
new foreign key value for the master side of the tuple. This shows up when you try to move off the
no longer new tuple -- .NET pops up a dialog box saying that the foreign key for the detail record
(-1) must be in the master record, and would you like to correct the problem? The -1 value, of
course, is the old/pre-Update() autosequence value for the new master record...so somehow the change
to the autosequence value is not being seen by the DataGrid.

This wouldn't be an issue except for the fact that I have an autosave feature built into my
application, so the SqlAdapter.Update() can occur at any time in the data entry process. I guess I
could work around this by making the autosave timer more "intelligent" (i.e., test to see if any
open form is in the middle of an edit and, if so, defer the autosave), but that feels kludgy.

Any suggestions?

- Mark
 
K

Kevin Yu

Yes Mark,

I agree with you. The Update cannot be called during an editing. Try to add
some flags for the auto save, so that it won't come up when you haven't
finished editing
--------------------
| NNTP-Posting-Date: Sun, 21 Sep 2003 17:55:39 -0500
| From: Mark Olbert <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.adonet
| Subject: Re: Problem w/SqlAdapter.Update on Child Tables
| Date: Sun, 21 Sep 2003 15:55:26 -0700
| Organization: Olbert & McHugh, Ltd.
| Reply-To: (e-mail address removed)
| Message-ID: <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| X-Newsreader: Forte Agent 1.93/32.576 English (American)
| MIME-Version: 1.0
| Content-Type: text/plain; charset=us-ascii
| Content-Transfer-Encoding: 7bit
| Lines: 31
| X-Trace:
sv3-s6dPIpC9RhewYPJaaKtciqRG4CfFH+/uQtkMVE8DFTCY4sQW2ThEH9PyN16ih/kaGmDZZd7U
06Z2JPz!aZg+7MIy5oCrl04WoG1Wimcp4sjIz1uFlXoJbmtk5kU09DoGkdZEYnttktnr+w/P2OpG
qg==
| X-Complaints-To: (e-mail address removed)
| X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
| X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
| X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your
complaint properly
| X-Postfilter: 1.1
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!newsfee
d01.sul.t-online.de!t-online.de!newspeer1-gui.server.ntli.net!ntli.net!peer0
1.cox.net!cox.net!border3.nntp.aus1.giganews.com!intern1.nntp.aus1.giganews.
com!nntp.giganews.com!news.giganews.com.POSTED!not-for-mail
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:61736
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| David,
|
| First off, allow me to be the 8,768th person to thank you for writing a
clear and comprehensive book
| on ADO.NET :) I just bought it, and it's already been very helpful.
|
| I >>think<< I've solved my master/detail update problem (although I've
thought that before) by using
| Select() and RowState to handle separately deletions, additions and
modifications, handling the
| master tables first for additions and modifications and last for
deletions. Although I still think
| ADO.NET should be handling something like this automagically when it
"knows" about the relations
| between DataTables.
|
| However, there seems to be a quirk in the DataGrid I use to bind to the
detail table on my form. If
| I create a new master/detail tuple, and move off of it (i.e., to a
different master record) then the
| master/detail update mechanism I've created works fine.
|
| But if I do an SqlAdapter.Update() on the new master/detail tuple while
it is the current record on
| the form, the update against SqlServer appears to work, but the detail
DataGrid doesn't "see" the
| new foreign key value for the master side of the tuple. This shows up
when you try to move off the
| no longer new tuple -- .NET pops up a dialog box saying that the foreign
key for the detail record
| (-1) must be in the master record, and would you like to correct the
problem? The -1 value, of
| course, is the old/pre-Update() autosequence value for the new master
record...so somehow the change
| to the autosequence value is not being seen by the DataGrid.
|
| This wouldn't be an issue except for the fact that I have an autosave
feature built into my
| application, so the SqlAdapter.Update() can occur at any time in the data
entry process. I guess I
| could work around this by making the autosave timer more "intelligent"
(i.e., test to see if any
| open form is in the middle of an edit and, if so, defer the autosave),
but that feels kludgy.
|
| Any suggestions?
|
| - Mark
|
 
M

Mark Olbert

Kevin,

Since your private email to me showed that you're a Microsoft employee, may I presume that your
comment is definitive about not being able to call Update while still "on" a newly-created record?
(I promise not to zing you guys on this one, although I will say this behavior is a shortcoming).

And, yes, I do find your post helpful, provided it's definitive, 'cause I won't waste any more time
trying to solve the problem another way.

- Mark
 
M

Mark Olbert

Kevin,

There doesn't seem to be any way to tell when a DataGrid control's row is being edited. I tried
looking at the CurrencyManager.Current.IsEdit property, but it is false even when the user is
editing a value in the grid.

I need to be able to tell when the DataGrid is editing if I'm going to not try to call
SqlAdapter.Update() during an edit. Any ideas? What am I missing?

- Mark
 
D

David Sceppa

Mark,

Thanks for the kind words regarding the book.

The DataAdapter's updating logic is designed to submit
changes for a single table. You're correct in noting that as a
result of this approach, handling submitting changes to a
hierarchy generally requires multiple calls to DataAdapter.Update
and DataTable.Select to submit inserts and updates in a top-down
fashion, but deletions in a bottom-up fashion.

Regarding the problem you're seeing with data binding and
cascading the newly fetched auto-increment value to the
appropriate children, could you provide a quick set of steps to
set up the bindings, insert the data, submit the changes and see
the behavior? I don't believe I've seen that behavior before and
want to make sure that you, Kevin and I are on the same page
regarding the scenario to look for a possible solution. Thank
you for your time.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2003 Microsoft Corporation. All rights reserved.
 
K

Kevin Yu

Hi Mark,

The DataGrid control doesn't offer such a property to tell you whether
you're editing a cell. You have to write some code of your own.

1. Handle the keypress event of the cell and set a flag to true, so that
the auto save will not fire.
2. Handle the CurrentCellChanged of the DataGrid and set the flag to false,
and the auto save might fire.

Since you cannot access the cell objects in the DataGrid directly and the
KeyPress event of DataGrid will not fire when you are typing a cell, you
have to handle the ControlAdded event of the DataGrid to get the cell
object reference.

Here's a code snippet I wrote to achieve this.

Add these to InitializeComponent()

private void InitializeComponent()
{
this.dataGrid1.ControlAdded += new
ControlEventHandler(this.dataGrid1_ControlAdded);
}

private void dataGrid1_ControlAdded(object sender, ControlEventArgs e)
{
e.Control.KeyPress += new
KeyPressEventHandler(this.dataGrid1_ControlKeyPress);
}

private void dataGrid1_ControlKeyPress(object sender, KeyPressEventArgs e)
{
this.bEditing = true;
}

private void dataGrid1_CurrentCellChanged(object sender, System.EventArgs
e)
{
this.bEditing = false;
}

Hope this helps.

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| NNTP-Posting-Date: Mon, 22 Sep 2003 14:40:41 -0500
| From: Mark Olbert <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.adonet
| Subject: Re: Problem w/SqlAdapter.Update on Child Tables
| Date: Mon, 22 Sep 2003 12:40:42 -0700
| Organization: Olbert & McHugh, Ltd.
| Reply-To: (e-mail address removed)
| Message-ID: <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| X-Newsreader: Forte Agent 1.93/32.576 English (American)
| MIME-Version: 1.0
| Content-Type: text/plain; charset=us-ascii
| Content-Transfer-Encoding: 7bit
| Lines: 10
| X-Trace:
sv3-dVbfH9RAeogEY6k5UwBc8hJEuFdFM593FNoXZ8dYaw3iaQaFhuT7QWj+wIkMFfbGEc0DlIS/
RVYBjhL!q6eeNC2+SVXfH/b+8u9bums8rClpSOThaC34qbSwkbaAf9udWVaZpiGM6O2SQ2W/lxXi
KQ==
| X-Complaints-To: (e-mail address removed)
| X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
| X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
| X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your
complaint properly
| X-Postfilter: 1.1
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onlin
e.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!peernews-us.colt.net!ne
wsfeed.news2me.com!newsfeed2.easynews.com!newsfeed1.easynews.com!easynews.co
m!easynews!border3.nntp.aus1.giganews.com!intern1.nntp.aus1.giganews.com!nnt
p.giganews.com!news.giganews.com.POSTED!not-for-mail
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.adonet:61827
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| Kevin,
|
| There doesn't seem to be any way to tell when a DataGrid control's row is
being edited. I tried
| looking at the CurrencyManager.Current.IsEdit property, but it is false
even when the user is
| editing a value in the grid.
|
| I need to be able to tell when the DataGrid is editing if I'm going to
not try to call
| SqlAdapter.Update() during an edit. Any ideas? What am I missing?
|
| - Mark
|
 
M

Mark Olbert

Kevin,

An interesting approach, and conceptually nicer than letting the user try to do a save only to be
told it just ain't possible at this time. I'll try it out and let you know how it works. Thanx!

- Mark
 
M

Mark Olbert

David,

Okay, I'll put together a cutdown example to demonstrate the problem. It'll take me a few days,
however, as I am currently drowning in alligators.

- Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top