开发者

convert ds.Tables[1].Rows[0].ToString() to int

I can't convert ds.Tables[1].Rows[0].ToString() to an int.

ds.Tables[1].Rows[0] = 100; 开发者_运维技巧

Gives an error can't convert.


string test = Convert.Int32(ds.Tables[0].Rows[0]["YourIntegerColumn"].ToString())

If your column isnt an integer, then it's not gonna work, so you'll probly want to check if the column is null, then check if its parsable to an int using Int.TryParse


ds.Tables[1].Rows[0] returns a DataRow. You need to indicate the column that you want to assign the value:

ds.Tables[1].Rows[0]["Your column name"] = value;


Are you missing the column? ds.Tables[1].Rows[0][column] = value;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜