Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3343328
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:56:31+00:00 2026-05-18T00:56:31+00:00

To revisit a previous question with a further stipulation… Anyone know how to do

  • 0

To revisit a previous question with a further stipulation…

Anyone know how to do the following, IGNORING CASE?

Dim Matches = From mRows In LinqMasterTable Join sRows In LinqSecondTable _
         On mRows(ThePrimaryKey) Equals sRows(TheForignKey) _
         Order By mRows(ThePrimaryKey) _
         Select mRows, sRows

For details about the query and it’s functions / usage, the previous post is here.

EDIT:

Here’s the kind of tables we’re querying:

LinqMasterTable:
 -------------------------------------
|ThePrimaryKey| Description           |
 -------------------------------------
|Green        | This is a Green apple | 
|GREEN        | This is a Green apple | 
|green        | This is a Green apple | 
|Red          | This is a Red apple   | 
|RED          | This is a Red apple   | 
|red          | This is a Red apple   | 
 -------------------------------------

LinqSecondTable
 --------------------------
|TheForignKey | ApplePrice |
 -------------------------- 
|Green        | $0.90      | 
|Pink         | $0.80      | 
|Red          | $0.85      | 
|Yellow       | $0.79      |
 --------------------------

And here’s the desired outcome:

 --------------------------------------
|Green | This is a Green apple | $0.90 |
|GREEN | This is a Green apple | $0.90 | 
|green | This is a Green apple | $0.90 |
|Red   | This is a Red apple   | $0.85 |
|RED   | This is a Red apple   | $0.85 |
|red   | This is a Red apple   | $0.85 |
 --------------------------------------

Unfortunately, the actual (undesired) result is this:

 --------------------------------------
|Green | This is a Green apple | $0.90 |
|Red   | This is a Red apple   | $0.85 |
 --------------------------------------

ReEdit:


Private Sub LinqTwoTableInnerJoinCaseInsensitive(ByRef qMasterDS As DataSet, _
                                  ByRef qMasterTable As DataTable, _
                                  ByRef qSecondDS As DataSet, _
                                  ByRef qSecondTable As DataTable, _
                                  ByRef qPrimaryKey As String, _
                                  ByRef qForignKey As String, _
                                  ByVal qResultsName As String)

    Dim TheMasterTable As String = qMasterTable.TableName 'Table Name'
    Dim TheSecondTable As String = qSecondTable.TableName 'Table Name'
    Dim ThePrimaryKey As String = qPrimaryKey 'The variable name of the first 'merge on' column'
    Dim TheForignKey As String = qForignKey 'The variable name of the second 'merge on' column'
    Dim TheNewForignKey As String = "" 'For handling duplicate column names'

    MasterTableColumns = GetColumns(qMasterDS, TheMasterTable)
    SecondTableColumns = GetColumns(qSecondDS, TheSecondTable)

    Dim mColumnCount As Integer = MasterTableColumns.Count
    Dim sColumnCount As Integer = SecondTableColumns.Count

    Dim ColumnCount As Integer = mColumnCount + sColumnCount

    Dim LinqMasterTable = qMasterDS.Tables(TheMasterTable).AsEnumerable
    Dim LinqSecondTable = qSecondDS.Tables(TheSecondTable).AsEnumerable

    'Original LINQ Query: (Works, but is case sensitive)'
    Dim Matches = From mRows In LinqMasterTable Join sRows In LinqSecondTable _
         On mRows(ThePrimaryKey) Equals sRows(TheForignKey) _
         Order By mRows(ThePrimaryKey) _
         Select mRows, sRows

    'IntelliSense doesnt see "ToUpper" as available. No errors, but no search results.'
    'Error: Public member "ToUpper" on type "DBNull" not found.'
    'Dim Matches = From mRows In LinqMasterTable Join sRows In LinqSecondTable _'
    '              On mRows(ThePrimaryKey).ToUpper Equals sRows(TheForignKey).ToUpper _'
    '              Order By mRows(ThePrimaryKey) _'
    '              Select mRows, sRows'


    'Message = "Public member "sRows" on type "String" not found."'
    'Dim Matches2 = From mRows In LinqMasterTable _'
                   'From sRows In LinqSecondTable _'
                   'Where String.Equals(mRows(ThePrimaryKey), sRows(TheForignKey), StringComparison.OrdinalIgnoreCase) _'
                   'Select mRows, sRows'


    'Conversion from type "DBNull" to type "String" is not valid.'
    'Dim Matches = _'
    'LinqMasterTable.AsEnumerable().Join( _'
    'LinqSecondTable.AsEnumerable(), _'
    'Function(mRows) mRows("ThePrimaryKey"), _'
    'Function(sRows) sRows("TheForignKey"), _'
    'Function(mRows As DataRow, sRows As DataRow) New With {mRows, sRows}, _'
    'StringComparer.InvariantCultureIgnoreCase)'

        'Doesnt work at all - multiple errors'
        'Dim Matches2 = _'
        'LinqMasterTable _'
        '    .Join( _'
        '        LinqSecondTable, _'
        '        Function(x) x.Key.ToLower(), _'
        '        Function(x) x.Key.ToLower(), _'
        '        Function(o, i) New With {.ID = o.Key, .Description = o.Value, .Price = i.Value} _'
        '    ).Dump()'


    ' Make sure the dataset is available and/or cleared:'
    If dsResults.Tables(qResultsName) Is Nothing Then dsResults.Tables.Add(qResultsName)
    dsResults.Tables(qResultsName).Clear() : dsResults.Tables(qResultsName).Columns.Clear()

    'Adds Master Table Column Names'
    For x = 0 To MasterTableColumns.Count - 1
        dsResults.Tables(qResultsName).Columns.Add(MasterTableColumns(x))
    Next

    'Rename Second Table Names if Needed:'
    For x = 0 To SecondTableColumns.Count - 1
        With dsResults.Tables(qResultsName)
            For y = 0 To .Columns.Count - 1
                If SecondTableColumns(x) = .Columns(y).ColumnName Then
                    SecondTableColumns(x) = SecondTableColumns(x) & "_2"
                End If
            Next
        End With
    Next

    'Make sure that the Forign Key is a Unique Value'
    If ForignKey1 = PrimaryKey Then
        TheNewForignKey = ForignKey1 & "_2"
    Else
        TheNewForignKey = ForignKey1
    End If

    'Adds Second Table Column Names'
    For x = 0 To SecondTableColumns.Count - 1 'Need error handling for if columnname exists'
        dsResults.Tables(qResultsName).Columns.Add(SecondTableColumns(x))
    Next

    PleaseWait(True) 'Locks controls while processing data'

    'Copy Results into the Dataset:'
    For Each Match In Matches

        'Build an array for each row:'
        Dim NewRow(ColumnCount - 1) As Object

        'Add the mRow Items:'
        For x = 0 To MasterTableColumns.Count - 1
            NewRow(x) = Match.mRows.Item(x)
        Next

        'Add the srow Items:'
        For x = 0 To SecondTableColumns.Count - 1
            Dim y As Integer = x + (MasterTableColumns.Count)
            NewRow(y) = Match.sRows.Item(x)
        Next

        'Add the array to dsResults as a Row:'
        dsResults.Tables(qResultsName).Rows.Add(NewRow)

    Next


    If chkUnique.Checked = True Then
        ReMoveDuplicates(dsResults.Tables(qResultsName), ThePrimaryKey)
    End If

    PleaseWait(False) 'Unlocks controls after processing data'

    If Not chkRetainKeys.Checked = True Then 'Removes Forign Key'
        dsResults.Tables(qResultsName).Columns.Remove(TheNewForignKey)
    End If

    'Clear Arrays'
    MasterTableColumns.Clear()
    SecondTableColumns.Clear()

End Sub

Incidentally, some additional information:

Dim MasterTableColumns As New ArrayList() 'Holds the Names of the Master Table Columns'
Dim SecondTableColumns As New ArrayList() 'Holds the Names of the Second Table Columns'
Dim MasterTable As String 'Current User Selected Master Table'
Dim PrimaryKey As String 'Table 0 User Selected Key'
Dim ForignKey1 As String 'Table 1 User Selected Key'


Private Function GetColumns(ByVal aDataset As DataSet, ByVal aTable As String) As ArrayList

    If aDataset Is Nothing Then Return Nothing

    If Not aDataset.Tables(aTable) Is Nothing Then
        Dim TempArray As New ArrayList()
        For x = 0 To aDataset.Tables(aTable).Columns.Count - 1
            With aDataset.Tables(aTable).Columns(x)
                TempArray.Add(.ColumnName)
            End With
        Next
        Return TempArray
    Else
        MsgBox("There are no column names in the table """ & aTable & """ to load.")
        Return Nothing
    End If

End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T00:56:32+00:00Added an answer on May 18, 2026 at 12:56 am

    Best Solution we could come up with:

    [1] Import XLS File1 to Dataset ds1 and XLS File2 to Dataset ds2

    [2] Allow user to Select the desired Merge-Using columns

    [3] Add UPPER column to ds1 and ds2

    [4] Copy Column Data over as Uppercase for both tables:

    For each dr as DataRow in ds1.Tables(0).Rows
      dr.Item(UPPER) = dr.Item(MixCaps).ToUpper
    Next
    

    [5] Merge tables using UPPER columns

    [6] Delete UPPER columns and output merged table

    I know this output doesn’t strictly use LINQ to Merge Case Insensitively, however it’s the best I could do within the deadline. Thanks for all the help guys. Wish the other ideas would have worked. Meh. Maybe next time.

    Party on Wayne.
    Party on Garth.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In case I have a need to revisit the previous data , while updating
This question has been asked many times before but none of the previous ones
A question for anyone who has used the Java library Mallet's SimpleTagger class for
I am looking for a way to inject values from the fragment (#) of
This is very similar to a question I asked the other day but my
This is very similar to a question I asked the other day but my
This is my first time using stackoverflow for a question, I have read a
Recently I have needed to use RMI, and I know enough for what I
I recently ran into a situation in which accessing session information from view is
At times I want to revisit a change I committed to SVN a short

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.