473,569 Members | 2,782 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2173
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*****@Create ItSoftware.net> wrote in message
news:OE******** ********@TK2MSF TNGP12.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(ADatas et.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***@bellsout h.net> wrote in message
news:%2******** ********@TK2MSF TNGP11.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*****@Create ItSoftware.net> wrote in message
news:OE******** ********@TK2MSF TNGP12.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.rowfil ter and the datatable.selec t
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
2564
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 DataView. (I'm writing in C# with the v1.1.4322 of the .NET Framework, in Window2K server"). First of all, here are the two methods I have used in order to...
12
2373
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 field... This grid displayes results based on users search.. public static int numberDiv; private void Page_Load(object sender, System.EventArgs e) {
2
945
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 datagrid. HTML Datagrid1 TemplateColumn Table Header information Detail Information
4
10028
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 have a .getxml method (unlike the dataset). any ideas? thanks.
4
2985
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 value(s) for the key being indexed, but received 1 value(s). I have tried the following: Dim Names(1) as Object
4
11135
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 ReportTable As System.Data.DataTable = New System.Data.DataTable("SendTo") The ReportTable is populated row by row by data gotten back from the
1
1151
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 and paging portions won't. If I just call the DisplayData() method then the Edit portion doesn't work. I found out that when sorting the sorting value...
0
7697
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8120
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6283
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1212
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.