Getting Column lengths
Posted: Wed 11 May 2005 18:03
As part of another process I need to get the lengths of the columns returned in a query. My test code for this looks like:
The messagebox always shows -1 though. Why isn't the column max length set?
Code: Select all
DataSet ds = new DataSet();
PgSqlDataAdapter da = new PgSqlDataAdapter("select * from insured where company_name ilike '%out%'", conn);
da.SelectCommand = new PgSqlCommand("select * from insured where company_name ilike '%out%'", conn);
da.Fill(ds);
DataTable insured_dt = ds.Tables["Table"];
insured_dt.TableName = "insured";
for (int i=0; i < (results.TableStyles["insured"].GridColumnStyles.Count-1); i++)
{
MessageBox.Show(insured_dt.Columns[i].MaxLength.ToString());
}