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 173153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:17:34+00:00 2026-05-11T13:17:34+00:00

I have a table with many values inside of it that might have single

  • 0

I have a table with many values inside of it that might have single quotes around them. I need to create a duplicate table without those single quotes. I can’t modify the original table as I need to use it, ‘as-is’ later.

I’ve done this with a table.Clone and using a foreach to loop through the rows and columns removing single quotes as I need and then putting that new row into the new table. It works and it’s straight forward…..but

I’d like to do the same thing using LINQ. This was my attempt….

        Dim myResults = From myRow In dtTable _                     From myItem In myRow.ItemArray _                     Where TypeOf myItem Is String AndAlso _                     myItem.ToString.StartsWith('''c) AndAlso _                     myItem.ToString.EndsWith('''c) 

As you can see – I didn’t get very far. I had trouble finding examples that weren’t looking at a specific column in the DataRow. It looks like my code does pull back all the matching results – but I’m at a lose for how I can create a duplicate table/modify the values?

EDIT – I’ve started a bounty for this in the hopes that someone can provide a solution. The only requirement is to not using a For Each; as I already know how to do that. I’ve gotten closer – but I still can’t seem to create a new row or a new table.

My new approach hits a dead-end when I try to do this:

Dim MyNewRow As New Data.DataRow With {.ItemArray = myRemovedQuotes.ToArray} 

The Error message I get says, ‘Error 1 ‘System.Data.DataRow.Protected Friend Sub New(builder As System.Data.DataRowBuilder)’ is not accessible in this context because it is ‘Protected Friend’.’

  • 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. 2026-05-11T13:17:35+00:00Added an answer on May 11, 2026 at 1:17 pm

    If you really must use LINQ (as a learning exercise, perhaps), then maybe something like below (as C#; my VB is nowhere near up to translating it, I’m afraid):

            DataTable clone = original.Clone();         string t;         var qry = from DataRow row in original.Rows                   let arr = row.ItemArray                   select Array.ConvertAll(arr, s =>                       (t = s as string) != null                       && t.StartsWith('\'')                       && t.EndsWith('\'') ? t.Trim('\'') : s);         foreach (object[] arr in qry) {             clone.Rows.Add(arr);         } 

    The problem is that the ItemArray needs to be expanded while retaining the separate rows (so SelectMany isn’t an option); Array.ConvertAll seems the easiest way.

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

Sidebar

Ask A Question

Stats

  • Questions 124k
  • Answers 124k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Are you running on OS 3.0? I saw the same… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer It looks like you need to register Apache::Session::Memcached with Apache::Session::Wrapper,… May 12, 2026 at 1:19 am
  • Editorial Team
    Editorial Team added an answer Use DATENAME or DATEPART: SELECT DATENAME(dw,GETDATE()) -- Friday SELECT DATEPART(dw,GETDATE())… May 12, 2026 at 1:19 am

Related Questions

Let's say I have four tables: PAGE , USER , TAG , and PAGE-TAG
I am trying to do a nice SQL statement inside a stored procedure. I
I have a few huge tables on a production SQL 2005 DB that need
I'm getting odd results from a MySQL SELECT query involving a LEFT JOIN ,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.