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
If you are eventually going to read the data, you can do this:
SqlCommand comm = new SqlCommand("SELECT * FROM Products", connection);
using (SqlDataReader reader = comm.ExecuteReader())
{
while (reader.Read())
{
Type type = reader.GetSqlValue(0).GetType();
// OR Type type = reader.GetSqlValue("name").GetType();
// yields type "System.Data.SqlTypes.SqlInt32"
}
}