How can i get the correct value of DataColumn.MaxLength

  • Thread starter Thread starter wjg
  • Start date Start date
W

wjg

hi all:

My c# code like this , and just like here on Microsoft web site :
http://support.microsoft.com/default.aspx?scid=kb;en-us;q317175


DataSet ds = new DataSet();
//myDataAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
myDataAdapter.Fill(ds, "Categories");
myDataAdapter.FillSchema(ds, SchemaType.Mapped);

DataTable mytable = ds.Tables["Categories"];
for (int i = 0; i < mytable.Columns.Count; i ++)
Console.WriteLine(mytable.Columns.MaxLength);


but DataColumn.MaxLength() does not work at all,
how can i do?
thanks!
 
Why did you comment out the MissingSchemaAction line? It is necessary to get
certain SQL information.

Kathleen
 
Try to call FillSchema first before calling Fill method such as:

myDataAdapter.FillSchema(ds, SchemaType.Mapped);
myDataAdapter.Fill(ds, "Categories");
 
Back
Top