Solved

BC30311: Value of type 'System.Data.DataView' cannot be converted to '1-dimensional array of System.Data.DataView'.

Posted on 2012-12-28
8
627 Views
Last Modified: 2012-12-28
I get the error "BC30311: Value of type 'System.Data.DataView' cannot be converted to '1-dimensional array of System.Data.DataView'." whith the below

 dvholidays = New DataView(dtholidays, "DATEPART(YEAR, Date) = " & e.Day.Date.Year & " AND " & "DATEPART(MONTH, Date) = " & e.Day.Date.Month, "", DataViewRowState.CurrentRows)


any idea why?
0
Comment
Question by:runnerjp2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 

Author Comment

by:runnerjp2005
ID: 38726591
If it helps im looking to do a foreach loop where DATEPART(YEAR, Date) = " & e.Day.Date.Year & " AND " & "DATEPART(MONTH, Date) = " & e.Day.Date.Month,  in the datatable if there is an easyer why of doing this
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 38726659
the error lies in the way you declared dvholidays  variable.
it should be :
Dim dvholidays  as DataView
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 38726661
if you declare the variable as array, you have to assign to a specific "slot" of the array:
dvholidays(1) = New DataView( ... )

or the like
0
Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

 

Author Comment

by:runnerjp2005
ID: 38726677
i now get the following error :S The expression contains undefined function call DATEPART().
DATEPART(YEAR, Date) = " & e.Day.Date.Year & " AND " & "DATEPART(MONTH, Date) = " & e.Day.Date.Month,
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 38726695
that's a new error ... should normally be a new question

anyhow, DATEPART is not a ADO function, so you cannot use it directly

you need to prepare the data in the underlying rowset in a way you can filter as needed.
either you have 2 fields containing only the year and month values; or you have the date field as string in format yyyymmdd etc ... and you can do >= '201101' and < '201201' if you want full year 2011 ...
0
 

Author Comment

by:runnerjp2005
ID: 38726705
what about between dates?
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 38726720
what I wrote above, you need to make the data in a way you can work correctly.
with dataviews, this can be tricky, as you don't have "all" the functions you may need to make it efficient.
note that usually, if the underlying sql can solve the filtering directly, especially if the filter would return only very few rows from a huge data set, you are better of querying with the filter direclty in the sql ...
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38726742
This question was asked (and probably answered) before I believe.

Execute a SQL to do the filtering from datasource (as probably already suggested).
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question