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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:39:43+00:00 2026-06-15T22:39:43+00:00

So I’ve got a excel sheet table and a mssql table, and the two

  • 0

So I’ve got a excel sheet table and a mssql table, and the two are being joined on excel table column 0 (first) and mssql column textfield2, using LINQ.
The problem I’m having when it’s joining alphanumeric values, which doesn’t seem to work. It does work when the values are numeric.

        var adapter = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", excconnectionstring);
        var adapter2 = new SqlDataAdapter("SELECT * FROM Table1", sqlconnectionstring);

        var ds = new DataSet();
        adapter.Fill(ds, "excel");
        adapter2.Fill(ds, "sql");

        var excel = ds.Tables["excel"].AsEnumerable();
        var esqel = ds.Tables["sql"].AsEnumerable();

        var query = from exc in excel
                    from sql in esqel
                    where exc[0].ToString() == sql.Field<string>("textfield2")
                    select new
                    {
                        debnr = sql.Field<string>("debnr"),
                        bedrag = double.Parse(exc[5].ToString())/100,
                        description = DateTime.Parse(exc[7].ToString(), new CultureInfo("nl-NL")).ToString("MMM yyyy"),
                        text1 = exc[0].ToString(),
                        projectno = sql.Field<string>("textfield1"),
                        central = sql.Field<string>("CentralizationAccount").Trim()
                    };

edit: Seems the alphanumeric do work when I order the values in the excel sheet with the alphanumeric values on top. But then I have the problem that it doesn’t work on the numeric values..

  • 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-15T22:39:44+00:00Added an answer on June 15, 2026 at 10:39 pm

    As others have said, the problem occurred due to the OleDb infering the column type based on the first couple of rows. Using Interop TextToColumn I change the excel column data type to Text. Here’s the code I use to do that:

            Workbook workBook = _excelApp.Workbooks.Open(Directory.GetCurrentDirectory() + "\\" + thisFileName,
                0, false, 5, "", "", false, XlPlatform.xlWindows, "",
    true, false, 0, true, false, false);
    
    
            object fieldInfo = new int[1, 2] { { 1, 2 } };
            Range _range = ((Worksheet)workBook.Worksheets.get_Item("Sheet1")).UsedRange.Columns[1, Type.Missing];
    
            _range.TextToColumns(
     _range, XlTextParsingType.xlDelimited,
     XlTextQualifier.xlTextQualifierNone, Type.Missing,
     Type.Missing, Type.Missing, Type.Missing,
     Type.Missing, Type.Missing,
     Type.Missing,
     fieldInfo,
     Type.Missing, Type.Missing);
    
            _excelApp.DisplayAlerts = false;
            _excelApp.ScreenUpdating = false;
            _excelApp.Visible = false;
            _excelApp.UserControl = false;
            _excelApp.Interactive = false;
    
            workBook.SaveAs(Directory.GetCurrentDirectory() + "\\" + thisFileName, Type.Missing, Type.Missing, Type.Missing,
            Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange,
            Type.Missing, Type.Missing, Type.Missing, Type.Missing,
            Type.Missing);
            workBook.Close(false, thisFileName, null);
            Marshal.ReleaseComObject(workBook);
            _excelApp.Quit();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I've tracked down a weird MySQL problem to the two different ways I was
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.