Use oledbconnection. getoledbschematable (oledbschemaguid. columns, new object [] {null, schemaname, tablename, null}) when obtaining the schema information of a column, the returned datatable column is "data_type ", is to use a number to identify the data type of the column. This number may be of the decimal or int32 type:
If "provider = msdaora.1;", the type of the column "data_type" is int32;
If "provider = oraoledb. Oracle;", the type of the column "data_type" is decimal.
After understanding the difference, the conversion error will not occur when converting the column data type to the string of the corresponding type in the oledbtype enumeration, because
Enum. getname (typeof (oledbtype), intvalue)
The second parameter of the method must be int32. Of course, Microsoft's driver does not solve this problem. If Oracle driver is used, decimal must be converted to int32 first.
In addition, I also found a problem: Among the parameters passed to the getoledbschematable () method, Microsoft drivers are case insensitive, but Oracle drivers must be capitalized. In fact, Oracle is not case sensitive in general SQL statements. Only when an oracle dictionary table is involved, Oracle requires that all object names be capitalized. Therefore, I guess the oledb driver implemented by Oracle actually reads dictionary tables such as user_tab_columns in the background. As an experience, the toupper () character string should be used when passing parameters.
Tutorial: I access the Oracle database in the project using the oracleclient namespace. However, I have never been right about which driver to use in oledb mode.