how to check if a datareader is null or empty

前端 未结 12 1743
谎友^
谎友^ 2020-12-24 01:52

I have a datareader that return a lsit of records from a sql server database. I have a field in the database called "Additional". This field is 50% of the time emp

12条回答
  •  执笔经年
    2020-12-24 02:31

    I also experiencing this kind of problem but mine, i'm using DbDataReader as my generic reader (for SQL, Oracle, OleDb, etc.). If using DataTable, DataTable has this method:

    DataTable dt = new DataTable();
    dt.Rows[0].Table.Columns.Contains("SampleColumn");
    

    using this I can determine if that column is existing in the result set that my query has. I'm also looking if DbDataReader has this capability.

提交回复
热议问题