Reading int values from SqlDataReader

后端 未结 6 1414
遥遥无期
遥遥无期 2021-02-02 08:18

hi can anyone please help me with this fetching from database of int values im having difficulty in fetching int values , it works for varchar but not int can someone help me ou

6条回答
  •  臣服心动
    2021-02-02 08:35

    Call ToString() instead of casting the reader result.

    reader[0].ToString();
    reader[1].ToString();
    // etc...
    

    And if you want to fetch specific data type values (int in your case) try the following:

    reader.GetInt32(index);
    

提交回复
热议问题