Description fa parte degli attributi estesi, non ho mai provato ma non credo (ma non ne sono sicuro) che si possa avere con .net
Magari il seguente codice ti può far comodo.
private void GeneraDataSet()
{
SqlConnection cn = new SqlConnection(cnText);
SqlCommand cm = new SqlCommand("SELECT *FROM mytable",cn);
SqlDataReader dr;
try
{
cn.Open();
dr = cm.ExecuteReader(CommandBehavior.KeyInfo);
DataTable schemaTable = dr.GetSchemaTable();
if (schemaTable != null)
{
ArrayList pkCols = new ArrayList();
DataTable dataTable = new DataTable();
dataTable.TableName = "menudef";
foreach (DataRow schemaRow in schemaTable.Rows)
{
DataColumn col = new DataColumn();
col.ColumnName = schemaRow["ColumnName"].ToString();
col.DataType = (Type)schemaRow["DataType"];
// set the length of the field for string types only
if (schemaRow["DataType"].ToString() == "System.String")
col.MaxLength = (Int32)schemaRow["ColumnSize"];
col.Unique = (bool)schemaRow["IsUnique"];
col.AllowDBNull = (bool)schemaRow["AllowDBNull"];
col.AutoIncrement = (bool)schemaRow["IsAutoIncrement"];
// If part of the key, add the column name to the
// array of columns comprising the primary key.
if ((bool)schemaRow["IsKey"])
pkCols.Add(col);
dataTable.Columns.Add(col);
}
// Add the primary key to the table.
if (pkCols.Count > 0)
dataTable.PrimaryKey =
(DataColumn[])pkCols.ToArray(typeof(DataColumn));
// Add the table to the DataSet.
dsDati.Tables.Add(dataTable);
object[] aData = new object[dataTable.Columns.Count];
// Read all rows from the DataReader.
while (dr.Read())
{
// Read the row from the DataReader into an array.
dr.GetValues(aData);
// Add the row from the array to the DataTable.
dataTable.Rows.Add(aData);
}
dr.Close();
dsDati.AcceptChanges();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
throw;
}
finally
{
if (cn.State == ConnectionState.Open)
cn.Close();
}
}