开发者

DataRow conversion issue in asp.net

开发者 https://www.devze.com 2023-04-11 17:20 出处:网络
How to convert system.data.datarow to an integer? I Have a da开发者_如何学Pythontarow which is returning the count of records which i want to store in an integer variable

How to convert system.data.datarow to an integer?

I Have a da开发者_如何学Pythontarow which is returning the count of records which i want to store in an integer variable The statement is as follows

int TotalRecords=ds.Tables[1].Rows[0];

here ds is the DataSet.

when i am trying to write the above statement it is telling me that i cannot implicitly convert System.Data.DataRow to int


You need to cast the value as an integer:

int TotalRecords = (int)ds.Tables[1].Rows[0]["YourColumnName"];


try that,

int TotalRecords=ds.Tables[1].Rows[0].Count();

you have to include Linq if not included

using System.Linq;
0

精彩评论

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

关注公众号