C
Chester.West2
In previous versions of .NET (1.0/1.1), I was able to get the easily
able to get a count of items contained in a SQL table by creating a
dataadapter with a select command similar to the following:
SELECT COUNT(*) from <tablename here>
In .NET 2.0, when you run the wizard to you can generate the same table
adapter...with .NET generating for you a partial class.
Works fine....Except if you have multiple tables!.. (unless of course
you don't mind generating a adapter, etc. for each and every table and
adding code to deal with it in whatever code that needs the count)
Why? Simple...Microsoft was smart enough to realize that you might
want to change the select statement....Therefore they made the
commandCollection PRIVATE (i.e. the _commandCollection cannot be
reached).
Now...I could modify the property and it public, or make a public
method....BAD IDEA!...Microsoft uses it smarts to determine if you've
made changes to the generated class...automatically re-generating and
wiping out your modifications for you (THANKS AGAIN MICROSOFT!)
I tried subclassing the partial class, but again it seems as if I still
couldn't get access to the
_commandCollection....although I'm not absolutely sure I'm subclassing
correctly.
DOES ANYBODY HAVE A SOLUTION to this problem ?????(other then creating
a old-style connection object along with a sql data adapter, and
setting things up)
ALSO...While I'm asking...I noticed that Microsoft automatically
generates non-scalable code for you when you use the wizard (i.e. they
generate using SQL Select statements, NOT stored procedures...to which
you can then add methods to call stored procedures...but Microsoft
seems to insure that you get left with code bloat since it doesn't
allow you to delete off the non-stored procedure sql statements).
able to get a count of items contained in a SQL table by creating a
dataadapter with a select command similar to the following:
SELECT COUNT(*) from <tablename here>
In .NET 2.0, when you run the wizard to you can generate the same table
adapter...with .NET generating for you a partial class.
Works fine....Except if you have multiple tables!.. (unless of course
you don't mind generating a adapter, etc. for each and every table and
adding code to deal with it in whatever code that needs the count)
Why? Simple...Microsoft was smart enough to realize that you might
want to change the select statement....Therefore they made the
commandCollection PRIVATE (i.e. the _commandCollection cannot be
reached).
Now...I could modify the property and it public, or make a public
method....BAD IDEA!...Microsoft uses it smarts to determine if you've
made changes to the generated class...automatically re-generating and
wiping out your modifications for you (THANKS AGAIN MICROSOFT!)
I tried subclassing the partial class, but again it seems as if I still
couldn't get access to the
_commandCollection....although I'm not absolutely sure I'm subclassing
correctly.
DOES ANYBODY HAVE A SOLUTION to this problem ?????(other then creating
a old-style connection object along with a sql data adapter, and
setting things up)
ALSO...While I'm asking...I noticed that Microsoft automatically
generates non-scalable code for you when you use the wizard (i.e. they
generate using SQL Select statements, NOT stored procedures...to which
you can then add methods to call stored procedures...but Microsoft
seems to insure that you get left with code bloat since it doesn't
allow you to delete off the non-stored procedure sql statements).