Stange behavior in dataview

M

Mike Cooper

Hi everyone,

I can't seem to get my dataview configured properly. I am using it on
a windows form to filter information from a datatable which is itself
populated from a dataset and ultimately, from a datasource (external
database). The datatable populates fine, but the dataview keeps
popping up errors when I try to configure it. Following is what I
have coded for it:

'OR_DataView
'
Me.OR_DataView.RowFilter = "'Main_DataColumn3 = Orlando and
Main_DataColumn25 = TRUE'"

Me.OR_DataView.RowStateFilter = System.Data.DataViewRowState.None
Me.OR_DataView.Table = Me.Main_Table
Me.OR_DataView.Sort = "Main_DataColumn3"

The .RowFilter and the .Sort parameters are giving me the most
trouble. The .RowFilter string is no longer giving me errors but I
have not been able to test it. No matter what I place in the .sort
field, I get the same error:

INVALID Entry, cannot find column.

I have tried all of the table columns, and for good measure those in
the dataset and even the datasource. If I try to set this parameter
in the properties gui, I get the above error immediately. If I try to
set it in the code I accepts it until I try to move to the form view,
at which point ALL of the parameters for the dataview disappear in
both code and gui!

I am using Visual Basic.net 2003. Can anyone tell me how I can
configure this?

Thanks,
Mike Cooper
 
W

William Ryan eMVP

In your select statement, what is the column name in the DataSet that
Main_DataColumn3 represents? In the TypedDataset, what is the name of the
column? For instance, if you used Select First_Name, Last_Name from
SomeTable and First_Name was the first field in your Typed DataSet, you'd
get a column name for First_Name and Last_Name in intellisense. Don't use
this name, use the name as it appears in your query.

That should do it for you....but let me know if it doesn't. Here's a sample
that might help you. http://www.knowdotnet.com/articles/expressions.html

HTH,

Bill
 
M

Mike Cooper

Hi William,

Thanks for responding. My select statement to populate the dataset is
simpley "Select * from Master_Schedule", where 'Master_Schedule' is
the name of a table in a MySql database. The dataset is untyped, so
there are no column definitions for it. The column Main_DataColumn3
is the designer name of a column in the 'Main_Table' which is a
datatable that is populated my my untyped dataset. I've tried the
regular columnname of the column as well without success

Do I need a typed dataset (or an XML schema?) to make the filter
properties of a dataview work? I have been able to create a dataview
of the whole table; in other words, to just display the entire table,
but I can't seem to limit the data displayed by the dataview in any
way. Since I am tying the dataview to the datatable, rather than the
dataset, I figured it wouldn't matter how the dataset was configured.

Let me know if I'm wrong here. I am new at database design.

Thank you,
Mike Cooper
 
M

Mike Cooper

Aha. I've got it. The Columnames of my table contained spaces. I
thought this was legal, since .net didn't object, but apparently
dataviews don't like them. When I replaced the spaces with
underscores my rowfilter and sort properties, which reference these
names, work fine.

Thanks again, for the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top