RowFilter and String?!

enjoy82

New member
Joined
Nov 22, 2005
Messages
2
Programming Experience
Beginner
Hello,
I am from germany, my English is not the best. But I hope I can find an answer for my problem, because I had no luck in different other forums.
I build a String with the StringBuilderClass.

dim rwStr as new System.Text.StringBuilder

After starting the procedure, the string contains...

rwStr = "PersNr = '6015' Or PersNr = '6072'" (and so on)

Now I tried to hand over the String to a RowFilter

Dim dv as new DataSet()
dv.RowFilter = rwStr.Tostring
DataGrid1.DataSource = dv

The Problem is, the RowFilter did not accept the string. The DataGrid showed no changes. (but also no fault/mistake)

If I hand over the same string by hand everthing is fine.
dv.RowFilter = "PersNr = '6015' .....

So my question is, is there any chance to deklare a variabel, which I can hand over to the RowFilter. The whole Code works towards to that string.
I am thankeful for every help.
Bye Conrad
 
i've had a little look at this proplem for you, and i've had little experience with the stringbuilder class, but from what i can gather to don't need to declare the stringbuilder object 'To.String' when you pass it to the dataset.

Also possibly if that doesn't work then rather than passing the stringbulder object directly to the dataset, you may have to be more specific and pass it to the datatable stored within the dataset.

hope this helps.
 
Do you have an example for passing the string directly to the dataset. The RowFilter is only available with the DataView - Object.
 
You do need to call ToString on a StringBuilder to get a String object. I doubt that the problem has anything to do with the StringBuilder. From the looks of things your PersNr column is supposed to contain numbers. Is that correct? By enclosing the values in single quotes you have made them strings. If they are supposed to numerical values rather than text then remove the single quotes and you'll probably find that things work as expected.

Just looked a bit further and noticed some anomolies with your code. You declare dv as a DataSet but the DataSet has no RowFilter property. Also, if it's a new DataSet then it has no data in it. If you have retrieved all your data into a DataTable then all you need to do is assign that DataTable to the DataSource of the DataGrid. Then, whenever you make changes to the DefaultView.RowFilter property of that DataTable the changes will be reflected in the DataGrid.
 
The only reason i say you don't need to declare the stringbuilder 'ToString' is that i've only worked with this in console applications, and there you can output the contents to the console window without using 'ToString' Sorry if that was wrong.
Hope Jmcilhinney got it sorted for you.:)
 
vis781 said:
The only reason i say you don't need to declare the stringbuilder 'ToString' is that i've only worked with this in console applications, and there you can output the contents to the console window without using 'ToString' Sorry if that was wrong.
Hope Jmcilhinney got it sorted for you.:)
That's because Console.WriteLine and the like are overloaded and one of the overloads takes a single Object argument. This is the overlaod that would be called if you passed a StringBuilder and presumably, given that it must write a string to the console, that overload calls the ToString method of the object internally.
 
hello ,
what u can do is create a dataset containing rows and place the stringbulider value in that , so assign this dataset to some datagrid
this would help for your query
 
Back
Top