Need help with DefaultView.RowFilter

  • Thread starter Thread starter gottfried.lesigang
  • Start date Start date
G

gottfried.lesigang

Dear everybody!

VS 2003, .Net 1.1

I've got a hierarchical DataStructure: MainGroup, SubGroup, Detail

On my form there is a combo to select the maingroup, dynamically a
second combo shows the fitting subgroups. Selecting one of them a grid
shows the fitting details... That works fine.

Now I want to choose all detailrows fitting to a chosen _main_group.
In this case the subgroup-combo is null.

That's my filter (ID-Types: Guid):

string filter=String.Format("DetailID IN (SELECT db1.DetailID FROM
Details AS db1 WHERE db1.SubGroupID IN(SELECT db2.SubGroupID FROM
SubGroups AS db2 WHERE
db2.MainGroupID='{0}'))",this.cboMainGroup.Value ); //in one long
line ;-)

I put a stop at this line, took the filter's content into a query
within SQL-Server. It workes perfectly?!?!

But on runtime a get an error when using the filter in
DefaultView.RowFilter ("missing operand after db1.")

Any ideas?
TIA
Gottfried
 
Hi Gotfried,

DataRow.Filter is not a full fledged SQL language - it is very primitive in
fact (it is mostly enough). But if you happen to have more complex queries
then I suggest a better approach.
- you might check out QueryADataset library
(http://blog.rthand.com/post/2007/02/22/QueryADataset.aspx)
- you might add a bool column (in memory) to the datatable, set it
accordingly to your condition and then filter on that column

Miha
 
Hi Miha!

I'm Sorry I did not answer earlier...
DataRow.Filter is not a full fledged SQL language - it is very primitive in
fact (it is mostly enough).

That seems to be true...

Thanks for your suggestions! I used the one with the added column.

Thx
Gottfried
 
Back
Top