开发者

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

开发者 https://www.devze.com 2022-12-11 02:38 出处:网络
I can\'t convert ds.Tables[1].Rows[0].ToString() to an int. ds.Tables[1].Rows[0] = 100; 开发者_运维技巧

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

精彩评论

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