I'm not sure what exactly I am doing wrong, can someone fix this, please? I need to determine the type of the extracted column from a SQL Server database using C #.
Say I have this:
SqlConnection cn = new SqlConnection("Sql Connection String");
SqlCommand cmd = new SqlCommand("SELECT * FROM [TableName]", cn);
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
for (int c = 0; c < rdr.VisibleFieldCount; c++)
{
System.Type type = rdr.GetFieldType(c);
}
}
source
share