Using GetSchemaTable() to retrieve only column names

后端 未结 4 875
无人共我
无人共我 2020-12-06 11:51

Is it possible to use GetSchemaTable() to retrieve only column names?

I have been trying to retrieve Column names (only) using this method, is it possi

4条回答
  •  天涯浪人
    2020-12-06 12:45

    Change your code to below if all you want is to display the column names. Your original code was trying to not only display column names, but also trying to display the actual data values as well.

    DataTable table = myReader.GetSchemaTable();
    
    foreach (DataRow myField in table.Rows)
    {
        foreach (DataColumn myProperty in table.Columns)
        {
            fileconnectiongrid.Rows.Add(myProperty.ToString());
        }
    }
    

提交回复
热议问题