Instance of dataview comes across as 'type Boolean' -- not sure why

A

Alex

Hey Everyone,

1: Public Function GetCustomerInfo(ByVal intCustomerID as Integer) as
DataView
2: Dim dtCustomerInfo As DataTable = _dtCustomerInfo
3: Dim dvCustomerInfo As DataView = _
4: dtCustomerInfo.DefaultView.RowFilter = "CustomerID= " +
CStr(intCustomerID)
5: Return dvCustomerInfo

Does anyone see an issue with these two statements? _dtCustomerInfo
is a datatable being populated earlier in the class, but I don't want
to modify the Defaultview so I created dtCustomerInfo to do the dirty
work within this function. The error I'm getting is this on line 4
(Entire line is underlined):
Value of type 'Boolean' cannot be converted to 'System.Data.DataView'.

It's acting like dtCustomerInfo.DefaultView.RowFilter = "CustomerID= "
+ CStr(intCustomerID) is of type Boolean instead of DataView. What am
I doing wrong? I even tried just using this;
dtCustomerInfo.DefaultView.RowFilter = "CustomerID=1"
.... but I get the same results.

Any suggestions? This is a WinForm using Visual Basic 2005.

Alex
 
S

Steve Gerrard

Alex said:
Hey Everyone,

1: Public Function GetCustomerInfo(ByVal intCustomerID as Integer) as
DataView
2: Dim dtCustomerInfo As DataTable = _dtCustomerInfo
3: Dim dvCustomerInfo As DataView = _
4: dtCustomerInfo.DefaultView.RowFilter = "CustomerID= " +
CStr(intCustomerID)
5: Return dvCustomerInfo

Does anyone see an issue with these two statements? _dtCustomerInfo
is a datatable being populated earlier in the class, but I don't want
to modify the Defaultview so I created dtCustomerInfo to do the dirty
work within this function. The error I'm getting is this on line 4
(Entire line is underlined):
Value of type 'Boolean' cannot be converted to 'System.Data.DataView'.

It's acting like dtCustomerInfo.DefaultView.RowFilter = "CustomerID= "
+ CStr(intCustomerID) is of type Boolean instead of DataView.

On line 3, you are assigning something to dvCustomerInfo. What are you
assigning? The entire expression on Line 4, which is a comparison of the
RowFilter of the default view to the string "CustomerID= " +
CStr(intCustomerID). A boolean, in other words.

If you want a new view (good idea), then do
Dim dvCustomerInfo As DataView = New DataView(_dtCustomerInfo)

You can then set the RowFilter property of the new view:
dvCustomerInfo.RowFilter = "CustomerID= " + CStr(intCustomerID)

One thing at a time, in other words.
 

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