Click here to Skip to main content
15,879,096 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
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
Updated 11-Oct-18 9:00am

1 solution

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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900