Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to filter Dataset in Vb.Net

Posted on 2014-12-26
9
Medium Priority
?
1,107 Views
Last Modified: 2014-12-28
My actual dataset - tempDS populates more than one datatable.

I need to filter the dataset for the DataTable : tree_categories

Sample query

select * from tree_categories where GROUP_CODE <> PA.43.948'

DataTable : tree_Categories

Column Name : GROUP_CODE


Dim tempDs As DataSet = ds
Dim dtTable As DataTable = tempDs.Tables("p_tree_categories")


How to filter a Dataset in Vb.Net ?
0
Comment
Question by:chokka
[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
  • 6
  • 2
9 Comments
 
LVL 3

Assisted Solution

by:Ali HND
Ali HND earned 1000 total points
ID: 40519347
Hi
Dim tempDs As DataSet = ds
Dim dtTable As DataTable = tempDs.Tables("p_tree_categories")
Dim result() As DataRow = dtTable.Select("GROUP_CODE <> 'PA.43.948'")
For Each row As DataRow In result
	    Console.WriteLine(row(0))
Next

Open in new window

0
 

Author Comment

by:chokka
ID: 40519348
@a_hnd , thank you !! I am returning the dataset in my function.

I am expecting the tempDS to be populated with filtered row of records and return in the function.

Is it possible to achieve in this syntax ??
0
 

Author Comment

by:chokka
ID: 40519358
actual method


Public Function LoadBaseTree(ByVal ds As DataSet) As Boolean

Dim result As Boolean = False

Dim tempDs As DataSet = ds

 

If BaseTreeLoaded = False Then

If ShowProductNotInElement = True Then
'implement function to append product not in element

tempDs = mergeTables(ds)


End If

result = MyBase.ApplySelectionCriteriaData(tempDs, Me.Name, GroupTableName, ItemTableName, GroupItemTableName, MyBase.ValidatorItemTableName, MyBase.ValidatorItemDataTableName, True, True, True, True)

If result = True Then
_baseTreeLoaded = True

End If

Else
ClearSelections()

result = True

End If
Return result
End Function

Open in new window

0
Independent Software Vendors: 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!

 
LVL 36

Accepted Solution

by:
Miguel Oz earned 1000 total points
ID: 40519361
The below code fills the temp dataset with the filtered info:
'create new dataset
Dim tempDs As DataSet = New DataSet()
'Use the merge method to add filtered table
tempDs.Merge(ds.Tables("p_tree_categories").Select( "GROUP_CODE <> 'PA.43.948'"))

Open in new window

0
 
LVL 3

Expert Comment

by:Ali HND
ID: 40519371
'Your Codes
'.
'.
'.
Dim result() As DataRow = dtTable.Select("GROUP_CODE <> 'PA.43.948'")
Dim FunctionResualt As Boolean = False
If result IsNot Nothing Then
    FunctionResualt = True
Else
    FunctionResualt = False
End If
Return FunctionResualt
End Function

Open in new window

0
 

Author Comment

by:chokka
ID: 40519747
When i write the merge syntax

tempDs.Merge(ds.Tables("p_tree_categories").Select( "GROUP_CODE <> 'PA.43.948'"))


My original ds has 23 tables.

On writing merge, i am able to get only p_tree_categories table. I am not  able to include remaining 22 tables.

In my req, i need to get all the tables in the Dataset. Along with filtered - p_tree_categories
0
 

Author Comment

by:chokka
ID: 40519772
tempDs.Merge(ds.Tables("p_tree_categories").Select( "GROUP_CODE <> 'PA.43.948'"))

tempDs.Merge(ds,True)

After writing the syntax,i am able to get the remaining 22 tables. Values populating the duplicate value of records.
0
 

Author Comment

by:chokka
ID: 40520085
I am merging all my ds.Tables to my test Dataset.

Issue is : testDs.Merge(ds.Tables("p_tree_data"))  - p_tree_data doesnt have row of records. When there is no row of records, table has to be merged with Dataset. Right now, when there is no row of records, table is not get merged. How to fix this issue
 

  Dim testDs As DataSet = New DataSet()

        testDs.Merge(ds.Tables("p_pay_cmp_cursor"))
        testDs.Merge(ds.Tables("p_pay_cmp_pln_cursor"))
        testDs.Merge(ds.Tables("p_currency_cursor"))
        testDs.Merge(ds.Tables("p_tree_categories").Select("SCR_DPY_SEQ <> '20116000'"))
        testDs.Merge(ds.Tables("p_tree_data"))
        testDs.Merge(ds.Tables("p_prod_override_cursor"))
        testDs.Merge(ds.Tables("p_tree_val_item"))
        testDs.Merge(ds.Tables("p_tree_val_item_data"))
        testDs.Merge(ds.Tables("p_bonus_cat_cursor"))
        testDs.Merge(ds.Tables("p_bonus_item_cursor"))
        testDs.Merge(ds.Tables("p_managed_results"))
        testDs.Merge(ds.Tables("p_tree_group_categories"))
        testDs.Merge(ds.Tables("p_component_type_cursor"))
        testDs.Merge(ds.Tables("p_ref_data_cursor"))
        testDs.Merge(ds.Tables("p_meas_typ_cursor"))
        testDs.Merge(ds.Tables("p_measurement_period_cursor"))
        testDs.Merge(ds.Tables("p_cap_typ_cursor"))
        testDs.Merge(ds.Tables("p_pay_calc_mth_cursor"))
        testDs.Merge(ds.Tables("p_calc_typ_cursor"))
        testDs.Merge(ds.Tables("p_pay_freq_cursor"))
        testDs.Merge(ds.Tables("p_payout_typ_cursor"))
        testDs.Merge(ds.Tables("p_perf_source_cursor"))
        testDs.Merge(ds.Tables("p_custom_type_cursor"))

Open in new window

0
 

Author Closing Comment

by:chokka
ID: 40520815
I am using merge syntax. Thank you Miguel.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

636 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