title: Checking the type of a SQL column in C#
body: <p>I have searched around here and found some threads relating to this problem but they didn't helped me. I need to check the type of a SQL column in a certain datatable and compare it. So let's say I have a column called "CustomerName" and this is a varchar in SQL. Then I want to compare it with a string or something else which is "varchar" and check if this matches. For example it should fail when my column has the type numeric and the string the value "varchar". I think the case with the string is a bad idea (for example when I've got varchar(50) and compare it to "varchar"). Is there a way to do that?</p>