title: How to find the DataBase type of a bound DataGridView column
body: <p>I need to know the original type of each column in my DataGridView.</p>
  
  <p>It is bound with a dynamic SQL select, say, <code>"SELECT * FROM artists;"</code></p>
  
  <p>I want to add a form view of the data above the grid and am programmtically creating Labels and TextBoxes and then some to hold the fields. I add them to a FlowLayoutPanel but I would like to adapt the sizes, especially the multiline property and the height to accomodate long comment and description fields of say 200-500 characters.</p>
  
  <p>All I found when looking into the text columns was datatype <code>string</code>.</p>
  
  <p>I know I can look up the columns by querying the systables, but it would be nice to find the original datatype a bit closer than that; also I'm using MYSQL atm, and a solution that doesn't need to query the database would hopefully also be DBMS independent.</p>
  
  <p><strong>Edit 1</strong></p>
  
  <p>I fill the DGV with nothing fancy:</p>
  
  <pre><code>DBDA = new MySqlDataAdapter(sql, DBC);
  MySqlCommandBuilder cb = new MySqlCommandBuilder(DBDA);
  DBDS = new DataSet(ddlb_tables.Text);
  DBDA.FillSchema(DBDS, SchemaType.Mapped);  //&lt;- This was the missing piece of code!!
  DBDA.Fill(DBDS, ddlb_tables.Text);
  dataGridView1.DataSource = DBDS;
  dataGridView1.DataMember = ddlb_tables.Text;
  </code></pre>
  
  <p><strong>Edit 2</strong></p>
  
  <p>With the help of the accepted answer (<code>DBDA.MissingSchemaAction</code>) I could solve my problem. Here is the resulting function in its first, raw version:</p>
  
  <pre><code>public int getColumnSize(DataGridViewColumn dc)
  {
    try
    {
      DataGridView DGV = dc.DataGridView;
      DataSet DS = (DataSet)DGV.DataSource;
      DataTable DT = DS.Tables[0];
      DataColumn DC = DT.Columns[dc.Name];
      return DC.MaxLength;
    } catch { }
    return -1;
  }
  </code></pre>
  
  <p>Not getting the original type is not a problem, as long as I know the length of the fields.</p>