0

I want to add first two columns of excel file into hashtable.. I wrote following code but it is giving me eror saying indexing not allowed in datacolumn...

Hashtable ExcelSheets = new Hashtable();
System.Data.DataColumn dc;
            // adding excel file into hash table
            if (dt1.Columns.Count > 0)
            {
                for (int c = 0; c < dt1.Columns.Count; c++)
                {

                   
                   
                    try
                    {
                        ExcelSheets.Add(dc[0].ToString().ToLower(), dc[1].ToString().ToLower());
                        
                    }

                    catch (Exception)
                    {

                    }

                }
            }

What 2 do?

2
Contributors
3
Replies
6
Views
6 Years
Discussion Span
Last Post by __avd
0

>What 2 do?

Please elaborate on your question.

Error says: indexing not allowed in datacolumn...so don't use indexing.

0

>What 2 do?

Please elaborate on your question.

Error says: indexing not allowed in datacolumn...so don't use indexing.

Then what is the alternate method of adding two columns in hashtable?
Indexing is allowed in datarow ... can we do it using data row ?... how ?

Edited by man3388: n/a

0

Not sure what you want.

Add two column name:

Hashtable ExcelSheets = new Hashtable();

ExcelSheets.Add(dt1.Columns[0].ColumnName,dt1.Columns[1].ColumnName)

Edited by mike_2000_17: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.