How can i get the correct value of DataColumn.MaxLength

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!
 
K

Kathleen Dollard

Why did you comment out the MissingSchemaAction line? It is necessary to get
certain SQL information.

Kathleen
 
Joined
Oct 31, 2008
Messages
1
Reaction score
0
Try to call FillSchema first before calling Fill method such as:

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top