Click here to Skip to main content
13,736,882 members
Rate this:
 
Please Sign up or sign in to vote.
See more:
I need to obtain and show the data that is in the DataTable

What I have tried:

DataTable dt = new DataTable();
                        conString = string.Format(conString, excelFile);

                        using (OleDbConnection connExcel = new OleDbConnection(conString))
                        {
                            using (OleDbCommand cmdExcel = new OleDbCommand())
                            {
                                using (OleDbDataAdapter odaExcel = new OleDbDataAdapter())
                                {
                                    cmdExcel.Connection = connExcel;


                                    connExcel.Open();
                                    DataTable dtExcelSchema;
                                    dtExcelSchema = connExcel.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                                    connExcel.Close();

                                    //Read Data from Specific Sheet And Range 
                                    connExcel.Open();
                                    cmdExcel.CommandText = "Select * from [" + "5.2" + "$A6:R100000]";
                                    odaExcel.SelectCommand = cmdExcel;
                                    odaExcel.Fill(dt);
                                    connExcel.Close();
                                }
                            }
                        }
Posted 11-Oct-18 8:50am
Updated 11-Oct-18 9:00am

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Well, identifying the goal is halfway to solving the problem.

Use intellisense to determine what method/property to use to "show the data". I would give you more guidance, but I don't have any skills regarding mind-reading and other associated technologies.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web01-2016 | 2.8.180920.1 | Last Updated 11 Oct 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100