newbie: bindingcontext prb

D

Dan

I have created a C# app which allows editing of some database tables in a
form. The form has several controls (text boxes, list boxes, etc), bound to
a dataset with some tables into it; whenever the user requests a specific
record from a list, the connection is opened and data are retrieved for the
single record and all the related ("children") tables; the controls are
filled and user can edit them.
When the user wants to store its data into the source database, I do the
following:

1) call BindingContext[myDataSet, "SomeTable"].EndCurrentEdit() for each
table in the dataset
2) call Update for each data adapter
3) call AcceptChanges if nothing went wrong

Anyway, sometimes I get an "object reference not set to instance of an
object" exception from some of the instructions at (1), i.e. the requested
BindingContext is null. What I'm doing wrong here?

Thanx to all!
 
Y

Yan-Hong Huang[MSFT]

Hello Dan,

Thanks for posting in the group.

Generally speaking, this error message happens when the object is invalid.
Could you please post the main code slice here so that we could repro the
problem? If you have any more concerns, please feel free to post here.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

Dan

Thanks, I think I have found this: some of the *simple* bindings have a
dataset as a source and a path to a specific field, e.g. "Products.name".
This is the path value I use when setting up the binding, but I have found
that when calling EndCurrentEdit I should rather call it with a path like
"Products" (the bare table name, no field name). At least, this seems to
work...
 

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