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

  • Home
  • SEARCH
  • 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 8619577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:22:26+00:00 2026-06-12T06:22:26+00:00

My goal is to trim all string datatypes within my dataset and then replace

  • 0

My goal is to trim all string datatypes within my dataset and then replace the “untrimmed” with the trimmed.

I encounter the following error:
“ArgumentException was unhandled – String was not recognized as a valid DateTime.Couldn’t store <> in DateofBirth Column. Expected type is DateTime.”

when I run the following code:

foreach (DataRow y in ds.Tables[0].Rows)
{
    for (int i = 0; i < ds.Tables[0].Columns.Count -1; i++)
    {
        if (y[i].GetType() != typeof(DateTime))
        {
            string strTrim = y[i].ToString().Trim();
            y[i] = strTrim;
        }
    }
}

I’m sure I’m on the right track, I just can’t manage to crack it :/

Any help will be appreciated!

  • 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-06-12T06:22:27+00:00Added an answer on June 12, 2026 at 6:22 am

    If you’re just looking for strings why are you checking for DateTime? Try:

    if (y[i] is string)
    {
        y[i] = ((string)y[i]).Trim();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Goal: Retrieve all instance of List<> from interface GameFactory Problem: I retrieve error message
Goal: Rolling/Running total for all statements at the end of each month. Code: select
Goal: create webservice that will query database and return rows, then pass it to
Goal Replace one div with another after 5 seconds delay using jQuery. Description I
The goal is that I would like to cycle through ALL of the .CSV
Goal... Given a Zip code and a number of miles... get all zip codes
Goal is to replace a integer value that is returned in a SQL query
Goal: write a query that can bring back all the users of a company,
Goal: I want to achieve the path address, as string, of the application created
Goal : I wants when I drag image it become fade so we can

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.