How to get the SqlType of a column in a DataTable?

前端 未结 7 456
予麋鹿
予麋鹿 2020-12-31 01:45

I have a DataTable obtained from a SQL DataBase, like this:

using (SqlCommand cmd = new SqlCommand(query, _sqlserverDB))
{
    using (SqlDataAdapter adapter          


        
7条回答
  •  悲&欢浪女
    2020-12-31 02:17

    If you are using DataReader -

    SqlDataReader reader = cmd.ExecuteReader(); reader.GetDataTypeName(int ordinal)

    should work if you want the SQL data type of a column

提交回复
热议问题