Question

I am using Pervasive and I would like to know what kind of data a column contains. However, the only overload of PsqlDataReader.GetFieldType accepts an int index. But I want to know using the column name. I guess I could just loop through all the columns and find the one with the specified name, but I do not want to do that.

Is there any way to find the data type of a column by a given column name?

Was it helpful?

Solution

You have to pair the use of GetFieldType with GetOrdinal (which returns the int index of the column):

PsqlDataReader.GetFieldType(PsqlDataReader.GetOrdinal("ColumnName"));

OTHER TIPS

I am not sure, but try use it like this

 SqlDataReader.GetFieldType["ColumnName"];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top