how i select min and max values from dataset

前端 未结 4 1937
北海茫月
北海茫月 2021-01-23 11:44

i want to retrive min and max value from dataset and those values use in for loop for display title in panel

    String sql = \"select  title, song_id from up_so         


        
4条回答
  •  灰色年华
    2021-01-23 12:04

    Make use of LINQ:

     var m = ds.Tables["title"].AsEnumerable().Max(x => x.Field("song_id"));
     var k = ds.Tables["title"].AsEnumerable().Min(x => x.Field("song_id"));
    

    Remeber that you have to add System.Data.DataSetExtensions to have DataSet.AsEnumerable() extension :)

提交回复
热议问题