string contor = ConfigurationManager.ConnectionStrings["sql"].ConnectionString; // private VideoLiveInfo SetRow(SqlDataReader rd) //获取一行的数据 { VideoLiveInfo row = new VideoLiveInfo(); row.Id = rd["id"].ToString(); row.LiveVideoUrl = rd["live_video_url"].ToString(); return row; }
//查询id最大的一条数据 public VideoLiveInfo FindMaxVideo() { string sql = "select * from dbo.VideoLive where id = (select MAX(id) from VideoLive)"; VideoLiveInfo vli = new VideoLiveInfo(); using (SqlDataReader rd = SqlHelper.ExecuteReader(contor, CommandType.Text, sql, null)) { if (rd.Read()) { vli = SetRow(rd); } return vli; } }