How to get data by SqlDataReader.GetValue by column name

后端 未结 3 757
野趣味
野趣味 2020-12-05 12:34

I use SqlDataReader.GetValue method to read values from DB:

Log.WriteLine(\"Value of CompanyName column:\" + thisReader.GetValue(1)); 

As p

相关标签:
3条回答
  • 2020-12-05 13:26

    You can also do this.

    //find the index of the CompanyName column
    int columnIndex = thisReader.GetOrdinal("CompanyName"); 
    //Get the value of the column. Will throw if the value is null.
    string companyName = thisReader.GetString(columnIndex);
    
    0 讨论(0)
  • 2020-12-05 13:35
    Log.WriteLine("Value of CompanyName column:" + thisReader["CompanyName"]); 
    
    0 讨论(0)
  • 2020-12-05 13:36

    thisReader.GetString(int columnIndex)

    0 讨论(0)
提交回复
热议问题