473,382 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Sorting a Dataview and Finding

Hello
I have created a Dataview and have sorted it on the Date and ShiftNumber
columns
this works great, but when I want to use the Find Method it gives me the
following error:
Expecting 2 value(s) for the key being indexed, but received 1 value(s).

I have tried the following:

Dim Names(1) as Object
Name(0) = TheDate
Name(1) = txtShiftNumber.text
X = ADataView.Find(Names)

and

X = ADataview.Find(TheDate)

Any assistance will be greatly appeciated.
Thank,
Chuck
Jul 21 '05 #1
4 2156
Hi,

You need to enclose the date in #. Try this.

Dim Names(1) as String
Name(0) = string.format("#{0}#",TheDate)
Name(1) = txtShiftNumber.text
X = ADataView.Find(Names)

Ken
-------------------
"Charles A. Lackman" <Ch*****@CreateItSoftware.net> wrote in message
news:OE****************@TK2MSFTNGP12.phx.gbl...
Hello
I have created a Dataview and have sorted it on the Date and ShiftNumber
columns
this works great, but when I want to use the Find Method it gives me the
following error:
Expecting 2 value(s) for the key being indexed, but received 1 value(s).

I have tried the following:

Dim Names(1) as Object
Name(0) = TheDate
Name(1) = txtShiftNumber.text
X = ADataView.Find(Names)

and

X = ADataview.Find(TheDate)

Any assistance will be greatly appeciated.
Thank,
Chuck

Jul 21 '05 #2
Thank You for you assistance but it did not work, I received an invalid cast
exception.

I am sorting the Dataview on two columns, I believe this is why it is
requiring two arguments for the sort. But when I try to give the Find to
arguments it underlines it.

I am sorting as such:
ADataView = New DataView(ADataset.Tables("Temp"))
ADataView.sort = "Date, Shift"

If I do not sort and Date and Shift It works just fine Finding the Date:

X = ADataview.Find(TheDate)

It's the 2 parameters that is giving me the problem.

Chuck
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi,

You need to enclose the date in #. Try this.

Dim Names(1) as String
Name(0) = string.format("#{0}#",TheDate)
Name(1) = txtShiftNumber.text
X = ADataView.Find(Names)

Ken
-------------------
"Charles A. Lackman" <Ch*****@CreateItSoftware.net> wrote in message
news:OE****************@TK2MSFTNGP12.phx.gbl...
Hello
I have created a Dataview and have sorted it on the Date and ShiftNumber
columns
this works great, but when I want to use the Find Method it gives me the
following error:
Expecting 2 value(s) for the key being indexed, but received 1 value(s).

I have tried the following:

Dim Names(1) as Object
Name(0) = TheDate
Name(1) = txtShiftNumber.text
X = ADataView.Find(Names)

and

X = ADataview.Find(TheDate)

Any assistance will be greatly appeciated.
Thank,
Chuck

Jul 21 '05 #3
This link
http://groups.google.com/groups?hl=e...3DN%26tab%3Dwg

suggests that the solution is to make sure that the order of the sort
keys and the values you are passing in the array should be the same, but
you seem to be doing that from what i see.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

Charles A. Lackman wrote:
Hello
I have created a Dataview and have sorted it on the Date and ShiftNumber
columns
this works great, but when I want to use the Find Method it gives me the
following error:
Expecting 2 value(s) for the key being indexed, but received 1 value(s).

I have tried the following:

Dim Names(1) as Object
Name(0) = TheDate
Name(1) = txtShiftNumber.text
X = ADataView.Find(Names)

and

X = ADataview.Find(TheDate)

Any assistance will be greatly appeciated.
Thank,
Chuck

Jul 21 '05 #4
Charles,

You have to decide which methode you use.
For the "find: you need to add or have a primary key to your datatable.

http://msdn.microsoft.com/library/de...sfindtopic.asp

You can as well use the dataview.rowfilter and the datatable.select
http://msdn.microsoft.com/library/de...ilterTopic.asp

Or the datatable select
http://msdn.microsoft.com/library/de...electTopic.asp

I hope this helps?

Cor

"Charles A. Lackman" <
Hello
I have created a Dataview and have sorted it on the Date and ShiftNumber
columns
this works great, but when I want to use the Find Method it gives me the
following error:
Expecting 2 value(s) for the key being indexed, but received 1 value(s).

I have tried the following:

Dim Names(1) as Object
Name(0) = TheDate
Name(1) = txtShiftNumber.text
X = ADataView.Find(Names)

and

X = ADataview.Find(TheDate)

Any assistance will be greatly appeciated.
Thank,
Chuck

Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: jwedel_stolo | last post by:
Hi I'm creating a dataview "on the fly" in order to sort some data prior to writing out the information to a MS SQL table I have used two methods in order to determine the sort order of the...
12
by: pmud | last post by:
Hi, I am using teh following code for sorting the data grid but it doesnt work. I have set the auto generate columns to false. & set the sort expression for each field as the anme of that...
2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
4
by: suzy | last post by:
hello. how can i sort data in a dataset? all the examples i have seen on msdn, etc are sorting a dataview. this works fine, but i want to return the results in xml and the dataview doesn't...
4
by: Charles A. Lackman | last post by:
Hello I have created a Dataview and have sorted it on the Date and ShiftNumber columns this works great, but when I want to use the Find Method it gives me the following error: Expecting 2...
4
by: =?Utf-8?B?R2VyaGFyZA==?= | last post by:
I have a vb.net 2.0 app that is loading a GridView with a DataSource that is returned from a function. The definitions in the function are: Dim ReportDS As DataSet = New DataSet Dim...
1
by: castron | last post by:
Hello All, I have a grid view that allows sorting, paging, editing, etc. Under On Load event, if I check: if(!IsPostBack){ DisplayData(); }, the Edit portion works fine. However, the Sorting...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.