Select Distinct Items From A BindingList?

Jun 5, 2010

I have set up a class to hold song information - artist, title. I then created another class that containg a BindingList(of clsSong). I use this binding list to create a data object that can be used to create an RDLC report. This all works. Now I am trying to remove duplicates from the binding list so they don't show up twice on the report. I can't figure out how to get a distinct list for my report. [code]...

View 3 Replies


ADVERTISEMENT

VS 2008 - Session Serialization And BindingList (Of Items)

Jan 28, 2010

I have created a huge monster based on generic objects and the BindingList. It is a web app that has users, security rights and restrictions, as well as the business logic to persist to the database. I have been using inProc sessions but each user creates about 50 megs of memory. I was initially told that would not be a problem, that a few users it at any time, and the items in the collections were supposed to be lot smaller, but I digress. For the amount of processing that the app has to do in real time, and for how it manages the data, the data it produces is 100%.

The speed and performance has been superior, but the only problem was it was on a box that was used for alot of other applications and it would run out of memory. I have since put it on Server 08 and have placed the Serializable attribute on all classes. I get a an error how ever when the web app tries to serialize the session. I get the feeling that there is an unsaid concensus that inheriting from BindingList is not supported by .net sql or state server session handling.

View 2 Replies

.net - Linq To Object - Select Distinct

Mar 18, 2010

I can't quite figure out why this Linq Statement isn't working as i would expect:

[Code]....

I would assume that this would create a new collection of anonymous types, that would be distinct. Instead it creates a collection the size of the "ThisParentCollection" with duplicate "MyAnonymousType" in it (duplicate id's).

View 1 Replies

Constraint Violation When Using Select Distinct?

Aug 6, 2009

I have a problem running a simple query: "select distinct payee from table". This query is set up in the dataset and is called GetAllPayee.My code goes something like:

Dim dtSources as new Datatable
dtSources =
Me.TblExpenseRecordsTableAdapter.GetAllPayee
Upon running I get the error:Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.The problem is, I haven't set ANY constraints on either the new datatable, or the dataset table (tblExpenseRecords). i.e. there is no primary key etc.

Can someone please help me out with this problem?I have no problems running the query through the wizard where I can view the results successfully.

View 3 Replies

DataView RowFilter - How To Select Distinct

May 29, 2003

Is it possible to select distinct in the rowfilter method?

I have something like:

VB
'Create a data view so we can get each items name
Dim dvwItemNames As New DataView(dtlItems)
dvwItemNames.RowFilter() = "SELECT DISTINCT Name"

This gives me a syntax error exception. I tried just "Distinct Name" but this had the same result. "Name" is the column name. I would rather do it this way then looping through the entire table and putting the name in an array list or something.

View 11 Replies

LINQ / Select Distinct From Dataset?

Aug 20, 2010

I have a single columned datatable inside a single tabled dataset.I just want to convert this dataset to distinct rows. Here is my code, it gives compile error '.' expected.

Dim query = _
From email In ds.Tables(0) _
Select email.Field<string>("Email").Distinct()

EDIT: I changed to (Of String) and it works... BUT NOW 'query' is an ienumerable collection of characters... not a datatable... so how do I convert back easily without manually doing a loop?

View 1 Replies

Select Distinct In Linq Query?

Jan 4, 2012

I've a collection with the data like this.[code]...

how can select the distinct data using linq?

View 2 Replies

Select Distinct Not Get Result Wanted

Jul 4, 2011

I used the following code to select unique values from the database [code]And it does not retrieve the unique values, it remains the same. But if I use only SELECT DISTINCT Author FROM tblBook it works fine.

View 3 Replies

Use Linq For Select Distinct Values?

Mar 28, 2012

I'm pretty new in Linq and the first problem I've is to select the Distinct values from a ObservableCollection( Of T)

I've tried with[code]...

View 2 Replies

Use Select Distinct From A Tables Row In MS Access?

Oct 29, 2010

I have a form with a list box The code loops through a Tables' row and gives me only one of each of the catergories. If more than one of a perticular item exist it only displays one. i would like to use Select Distinct instead just because it would cut down on the time it would take to read the Rows items and still give me the same results I just am not sure how to write it.

[Code]...

View 4 Replies

LINQ To SQL Select Distinct From Multiple Colums?

Apr 2, 2010

I'm using LINQ to SQL to select some columns from one table. I want to get rid of the duplicate result also.

Dim customer = (From cus In db.Customers Select cus.CustomerId, cus.CustomerName).Distinct

Result:

1 David
2 James
1 David
3 Smith
2 James
5 Joe

Wanted result:

1 David
2 James
3 Smith
5 Joe

Can anyone show me how to get the wanted result?

View 3 Replies

Select Distinct Rows From Datatable In Linq

Jul 14, 2010

I am trying to get distinct rows based on multiple columns (attribute1_name, attribute2_name) and get datarows from datatable using Linq-to-Dataset.[code]How to do thin Linq-to-dataset?

View 3 Replies

VS 2010 Select Distinct Values From A DataTable?

Sep 28, 2010

Is it possible to select distinct values from a DataTable?

View 5 Replies

Getting Count Of Non-distinct Items In List(of String)?

Feb 7, 2012

On to my question.I have a List(of String) that contains multiple items in each index.

A list declared as:

Dim NewStrings As New List(Of String)
May contain the following:
item (0) - (1 MKNO ABC 2.45 STND 3.3)
item (1) - (1 MKGO ABC 1.34 STND 2.5)
item (2) - (1 MKNO ABC 2.45 STND 3.3)
item (3) - (1 MKNO ABC 2.45 STND 3.3)

[Code]...

View 3 Replies

C# - LINQ Select Distinct While Evaluating Multiple Rows

Jul 11, 2011

I have an EnumerableRowCollection that looks like the following:
VendorCode | GroupType | Variance
01165 G .16
01165 G .16
01165 CH .16
01165 CH .18
07754 G .25
07754 G .25
07754 G .39

Essentially, this is a massive list of vendor codes, their groups, and price variances. I need to compose a query that will create a distinct list vendor codes and group types. The catch, however, is that I need to evaluate all of the variances associated with that particular VendorCode/GroupType to see if they are all the same - it they are not, I need to return some way of signifying that the group has a "custom" variance, otherwise it needs to return the value (ie: if they are all .16, then return .16, if there are multiple values, return "custom")

The result would look like this, based off of the list I showed above.
VendorCode | GroupType | Variance
01165 G .16
01165 CH custom
07754 G custom

I have no trouble getting a distinct list of VendorCode/GroupType - this is what I have so far:
Dim distinctList = From q In query Select q.VendorCode, q.GroupType, (evaluated q.Variance here?) Distinct
(where "query" is an EnumerableRowCollection(Of (anonymous type)))
I'm at a loss, though, on how to evaluate the variance property to get the result that I need?

View 1 Replies

C# - LINQ Select From IEnumerable With Distinct/GroupBy And Sorting?

Oct 19, 2010

My particular example is fairly complex but I think the concept would apply equally to something like a logging system so I'll use that instead for ease of explanation. It's a ficticious example, please don't harp on or agonise over what is achitectually, programatically or morally wrong with the example itself

[Code]...

I don't want to 'cheat' and resort to a long-winded way of doing it when performance isn't critical here and I'm moderately confident it can be done in a single LINQ statement.

View 1 Replies

Finding Distinct Element From Array Before Select Statement?

Nov 8, 2009

I have an array with wild character at the end. I use the value in this array in Select statement. Some times the array has same values. I want only distinct values in the array before the select statment.
Code:
for i=0 to count
select * from tbl where item like ' " & itemname(i) & "'
next
I need distinct element in itemname array.

View 1 Replies

Linq To Datarow, Select Multiple Columns As Distinct?

Apr 16, 2010

basically i'm trying to reproduce the following mssql query as LINQ

SELECT DISTINCT [TABLENAME], [COLUMNNAME] FROM [DATATABLE]

the closest i've got is

Dim query = (From row As DataRow In ds.Tables("DATATABLE").Rows _
Select row("COLUMNNAME") ,row("TABLENAME").Distinct

when i do the above i get the error

Range variable name can be inferred only from a simple or qualified name with no arguments.

i was sort of expecting it to return a collection that i could then iterate through and perform actions for each entry. maybe a datarow collection?

As a complete LINQ newb, i'm not sure what i'm missing.
i've tried variations on

Select new with { row("COLUMNNAME") ,row("TABLENAME")}

and get:

Anonymous type member name can be inferred only from a simple or qualified name with no arguments.

to get around this i've tried

Dim query = From r In ds.Tables("DATATABLE").AsEnumerable _
Select New String(1) {r("TABLENAME"), r("COLUMNNAME")} Distinct

however it doesn't seem to be doing the distinct thing properly.

View 3 Replies

VS 2008 Databinding Combobox With Distinct 'Category' Items Only?

Apr 19, 2011

I got a combobox that I populate with items by using databinding options which works fine, but what if I only want to only select the distinct items, was trying to do that but no avail so far. if I could do that just by using an sqladapter in code but is that what I should really do ?

View 2 Replies

VS 2010 : Display Distinct Items From A Column In A Checked List Box?

Mar 6, 2012

I want to display distinct items from a column in a checked list box then make a selection or selections and perform commands based on info from a second column in that database the database is a small Access 2010 database in the application directory right now I added the data source and items dont display even though I selected that source in the checked list box properties

Dataset = MyDataSet1
CheckedListBox = MyListBox1

I tried it with a combo box and it shows items but includes duplicates, did I setup the datasource wrong?

View 2 Replies

Asp.net - Select Distinct Rows From A Datatable With Criteria Involving Multiple Columns Using LINQ

Mar 9, 2012

I have a datatable as shown in the figure. Let me explain my required based on this image. I have 7 rows of data. The rows 1 and 2 contains columns till UnitSqcNo same. I want only row 3 among the two. In general I want select all the rows with distinct model, unittype, unit and rest with greater CompId. ie the table should look like

View 1 Replies

SQL Select Distinct Statement Fails To Execute Properly But Fine Is Access Directly?

Feb 6, 2011

Office 2010; Windows7; Visual Studio Basic 2008 (VB.Net)

[Code]...

The following strSQL string is not working as expected when run in VB.Net Interop to Access: (NOTE: The line-feeds " _" are used below are for reading only - are not in actual code line)

[Code]...

View 14 Replies

C# - Get Distinct Rows From Datatable Using Linq (distinct With Mulitiple Columns)

Jul 13, 2010

I am trying to distinct on multiple columns and get datarows from datatable. but getting error.

Dim query As IEnumerable(Of DataRow) =
(From row As DataRow In SourceTable.AsEnumerable() _
Select row.Field(Of String)("ColumnName1"),

[Code]....

I want another datatable with distinct row based on given columns from SourceTable.

View 3 Replies

Combobox Select - 2 Items From Single Select

Mar 7, 2012

I am a beginer in vb.net. For a school project, i have chosen inventory control as the subject. WIth help from videos, i have developed some basic forms with adding/updating.

The product table design is like this:

Name
Type
Size

[Code]...

Now, i am designing the purchase/sales screens. I am showing the items name, qty, price in a datagrid. From the products table, I am able to select the 'ProductName' by giving it a combobox . I want the ProductSellingPrice also to appear in the next column of the grid.

View 10 Replies

Take Clone Of BindingList Object

Mar 10, 2011

I have a object collection type of BindingList(of T), i want to take same copy of the object. but the problem is when ever i made the changes in the copy then the original object also reflect that change, how can i avoid it .

View 1 Replies

Using Bindinglist As Bind For Textbox?

Sep 9, 2010

I have a bindinglist. i am using a textbox to show its itemsWithEvents xBind As New BindingList(Of Emp)

I added items this way
xBind.Add(New emp("alpha0", "B"))
xBind.Add(New emp("alpha1", "B"))

[code].....

View 1 Replies

.net - Getting The Index Of Deleted Item From Bindinglist?

Aug 7, 2009

I am able to get the index of items added to the BindingList. When I try to get the index if the deleted item I get the error Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

Here is my code

Private Sub cmdRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRemove.Click

For i As Integer = 0 To _assignedSelection.SelectedCount - 1
Dim item As Jurisdiction = CType(_assignedSelection.GetSelectedRow(i), Jurisdiction)
_list.Remove(item)
Next
End Sub

Private Sub list_Change(ByVal sender As Object, ByVal e As ListChangedEventArgs) Handles _list.ListChanged

[Code]...

View 2 Replies

Binding Two BindingList<of T> Object To The Grid?

Jan 18, 2009

Is is possible to bind two BindingList<> object to the DataGridView? Both the bindinglist objects are of the same type. I tried binding an array of BindingLit<> object to the grid, but this fails.

View 3 Replies

Reflection - Getting Item Type Of A Bindinglist

May 27, 2010

I am trying to write a function that has an object parameter. That object will always be an BindingList. That BindingList will be of some unknown (at design Time) class. I think I've figured out how to get the type of the collection object, but now here the tricky part. I'm trying to create a function that can handle any type of collection and be able to return an item from that collection. I need to create a new object of that type and return it from the function. [Code]

View 1 Replies

Use BindingList(of T) To Bind To A Listbox Or A Datagridview?

Nov 16, 2009

I am using VB.net 2005 I have a form with a DataGridView on it called "DG"

Here is my Code:Option Explicit On Option Strict On Imports System.ComponentModel

[Code]...

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved