2个回答
展开全部
261372357或许我可以帮你 public static List<RoomType> GetAllRoomType() { string sql = "select * from roomType"; List<RoomType> list = new List<RoomType>(); using (DataTable table = DBHelper.GetDataSet(sql)) { foreach (DataRow reader in table.Rows) { RoomType type = new RoomType(); type.TypeId = (int)reader["typeID"]; type.TypeName = (string)reader["typeName"]; type.TypePrice = (decimal)reader["typePrice"]; type.AddBedPrice = (decimal)reader["addBedPrice"]; type.IsAddBed = (string)reader["isAddBed"]; type.ReMark = (string)reader["reMark"]; list.Add(type); } } return list; } //执行带参数的查询数据库操作返回DataTable public static DataTable GetDateSet(string sql, SqlParameter value) { SqlCommand command = new SqlCommand(sql,Connection); command.Parameters.Add(value); DataSet dataSet = new DataSet(); SqlDataAdapter adapter = new SqlDataAdapter(command); adapter.Fill(dataSet); return dataSet.Tables[0]; } 这是不带参的,带参就是在sql语句里用,可以加上 界面上用 this.gridview.DataSource=GetAllRoomType(); gridview1.DataBind();
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询