Saturday, February 25, 2012

Capturing events in a DataGrid

I'm trying to add functionality to a VB 6 application allowing
customer service to add a customer number to a new customer.
Customers are added to the database by sales personnel, and a
prospective customer may have multiple rows due to projected orders
for multiple products. Customer numbers are assigned when a new
customer makes their first order.

I'm using a DataGrid connected to an ADO Data Control. The data
control is connected to a view in SQL Server using the 'distinct'
directive (I know it's not updatable) to show only one line per new
customer. What I wish to do is capture the update event (probably
through the FieldChangeComplete routine of the data control), manually
assign the newly entered customer number to all appropriate rows in
the database, and cancel the update event with no notifications.

I'm having two problems:

1. I can't capture the newly entered customer number. The Text
property of the DataGrid returns the old value of the cell instead of
the newly entered value. How do I get the edited value?

2. Even though I set adStatus = adStatusCancel in the
FieldChangeComplete routine, I get a Microsoft DataGrid Control dialog
stating 'Operation was Canceled'. How do I avoid this notification?Bill Reynolds (TruckeeBill@.ltol.com) writes:
> I'm trying to add functionality to a VB 6 application allowing
> customer service to add a customer number to a new customer.
> Customers are added to the database by sales personnel, and a
> prospective customer may have multiple rows due to projected orders
> for multiple products. Customer numbers are assigned when a new
> customer makes their first order.
> I'm using a DataGrid connected to an ADO Data Control. The data
> control is connected to a view in SQL Server using the 'distinct'
> directive (I know it's not updatable) to show only one line per new
> customer. What I wish to do is capture the update event (probably
> through the FieldChangeComplete routine of the data control), manually
> assign the newly entered customer number to all appropriate rows in
> the database, and cancel the update event with no notifications.
> I'm having two problems:
> 1. I can't capture the newly entered customer number. The Text
> property of the DataGrid returns the old value of the cell instead of
> the newly entered value. How do I get the edited value?
> 2. Even though I set adStatus = adStatusCancel in the
> FieldChangeComplete routine, I get a Microsoft DataGrid Control dialog
> stating 'Operation was Canceled'. How do I avoid this notification?

Sounds like you should ask in an ADO group. Or maybe even a pure VB
group. If you insist on asking here, we will only tell you to use stored
procedures and not relying on things happening behind the scenes. :-)

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

No comments:

Post a Comment