You can use the INFORMATION_SCHEMA views in SQL Server, through a regular
Command, if your database is SQL Server. Or use
OleDbConnection.GetOleDbSchemaTable with an OLE DB provider that supports
Or you can do a DataAdapter.Fill with a MissingSchemaAction of
MissingSchemaAction.AddWithKey. Then refer to DataColumn.MaxLength. Or use
CommandBehavior.KeyInfo or SchemaOnly and look at the DataReader's SchemaTable.