I\'m trying to determine at runtime what the SqlDbType of a sql server table column is.
is there a class that can do that in System.Data.SqlClient or should I do the
For SQL Server, use the SMO (SQL Server Management Objects).
http://www.yukonxml.com/articles/smo/
For example, you can use this code to traverse over all of the columns of a table.
Server server = new Server();
Database database = new Database( "MyDB" );
Table table = new Table( database, "MyTable" );
foreach ( Column column in table.Columns )
{
WriteLine( column.Name );
}
Here are all of the column properties available to you: http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.smo.column_members.aspx