Hi Frank
As I understand the source of the problem is that
the first connection to a data occurs in the typed viewset constructor, i.e.
your event handler is being attached after the connection has been
established.
A couple of ways how to work around this
problem:
1) Define an event handler inside the typed viewset
definition, as a part the typed viewset class. Yom may expose some public
property somewhere in your application that is visible from within the typed
viewset class that keeps a necessary connection info.
2) Add a constructor to the typed viewset with a
parameter of the ConnectionOpeningEventHandler type, and store the passed value
in a local field, e.g.:
private ConnectionOpeningEventHandler
_connOpCallBack = null;
public MyTypedViewSet(ConnectionOpeningEventHandler
connOpCallBack): this()
{
_connOpCallBack =
connOpCallBack;
}
Define the ConnectionOpening event handler inside
the typed viewset with the codelike this:
if (_connOpCallBack != null)
_connOpCallBack(this,
e);
Then create a viewset instance by means of this
constructor:
MyTypedViewSet vs = new MyTypedViewSet(new
ConnectionOpeningEventHandler(myHandler));
Please let me know if neither of these suggestions
are appropriate.
Thanks,
Alex
Hello
Alex,
I tried to make a use of the ConnectionOpening event of the
C1TypedDataViewSet in my project
and got into the folowing problem.
The
event is not fired for the very first time the underlying .net TypedDataSet
retrieves the data
from the database. The event handler is assigned just
after the initializing line of the
C1TypedDataViewSet:
c1DataViewSet_MySet = new
C1DataViewSet_MySet();
c1TypedDataViewSetConnectionOpening +=
newC1.C1DataExtender.ConnectionOpeningEventHandler(
this.c1TypedDataViewSet_MySet_ConnectionOpening);
The only code inside
the handler is a MessageBox.Show("Test") call.
My intention however was to
change the connection string prior to any data access activity.
There
is a C1TrueDBGrid on the Form, bound to a C1DataView defined in
c1TypedDataViewSet_MySet. The Grid displays the data without the event having
been fired
and so I get an error if any modification to connection string
has been needed. Any data manipulation after this first time fires the event
as expected.
There are project level
C1TypedDataViewSet(Version=2.0.20062.32) and ADO.NET DataSet 2.0 DataSet
used.
Do You have any ideas concerning this matter?
Thanks a
lot!
Regards
C#_Frank
http://home.componentone.com/cs/forums/181869/ShowPost.aspx#190374