Database Error: There is no row at position 0

前端 未结 4 1016
囚心锁ツ
囚心锁ツ 2020-12-07 00:46

I believe this question was asked several months back, but i believe my situation is different and the same rules may not apply.

Everytime I execute this method tha

4条回答
  •  粉色の甜心
    2020-12-07 01:15

    This is very simple ... it means that no results were returned from your query. You always have to code defensively and check to see if the Rows array has any items in it before trying to index into it. Something like:

    if (dt.Rows.Count > 0)
        soptype = dt.Rows[0]["SOPTYPE"].ToString();
    else
        somethingWentWrong();
    

提交回复
热议问题