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
632 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
Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

695 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