I am using .NET with sql/oracle server.
I want to get the schema(datatype,columnname,etc…) of the sql result from:
SELECT *
FROM tablename
…or:
SELECT customername, companyname
FROM tablename
I do not want to execute for the real data. I just want to get the metadata behind that result without executing this statement… It worked in C++ but how in Ado.Net with C# ?
Create a Command, then look at ExecuteReader, and specifically, the CommandBehaviour SchemaOnly:
The documenations also mentions some SQL Server specifics, but handily I was just browsing the OracleClient classes, and they seem to respect this flag also. I don’t know if it’s guaranteed for other database providers.