在VS平台下用C#语言中显示数据库表中的某一个个人的全部记录包括(标题,正文,时间)求代码

比如显示一个人在一个月写的日记包括(标题,正文,时间)代码简单一点的... 比如显示一个人在一个月写的日记包括(标题,正文,时间)代码简单一点的 展开
 我来答
匿名用户
2011-10-10
展开全部
//Flower类
public class Flower
{
string _flowerid = "";
string _categoryid = "";
string _flowername = "";
string _flowerbh = "";
string _flowerpack = "";
string _price ="";
string _memberprice ="";
string _flowerpic = "";
string _description="";
string _postdate = "";
public Flower(string flowerid)
{
DataTable dt = DB.ExecuteDataTable("select * from Flower where FlowerId=" + flowerid );
foreach (DataRow dr in dt.Rows)
{
_flowerid = dr["FlowerId"].ToString();
_categoryid = dr["CategoryId"].ToString();
_flowername = dr["FlowerName"].ToString();
_flowerbh = dr["FlowerBh"].ToString();
_flowerpack = dr["FlowerPack"].ToString();
_price = dr["Price"].ToString();
_memberprice = dr["MemberPrice"].ToString();
_flowerpic = dr["FlowerPic"].ToString();
_description = dr["Description"].ToString();
_postdate = dr["PostDate"].ToString();
}
}
public string FlowerId { get { return _flowerid; } }
public string CategoryId { get { return _categoryid; } }
public string FlowerName { get { return _flowername; } }
public string FlowerBh { get { return _flowerbh; } }
public string FlowerPack { get { return _flowerpack; } }
public string Price { get { return _price; } }
public string MemberPrice { get { return _memberprice; } }
public string FlowerPic { get { return _flowerpic; } }
public string PostDate { get { return _postdate; } }
public string Description { get { return _description; } }
}

//DB类
public class DB
{
#region 静态全局变量 连接字符串
protected static string ConnectionStr = ConfigurationManager.ConnectionStrings["SqlConn"].ConnectionString;
#endregion

#region ExecuteDataTable(string sqlstr)
/// <summary>
/// 返回指定Sql语句的DataTable
/// </summary>
/// <param name="sqlstr">传入的Sql语句</param>
/// <returns>DataTable</returns>
public static DataTable ExecuteDataTable(string sqlstr)
{
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();
SqlConnection Conn = new SqlConnection(ConnectionStr);
SqlCommand Cmd = new SqlCommand(sqlstr, Conn);
try
{
Conn.Open();
da.SelectCommand = Cmd;
da.Fill(dt);
}
catch (Exception e)
{
Debug.WriteLine("ExecuteDataTable: " + e.Message);
throw new Exception(e.Message);
}
finally
{
Cmd.Dispose();
Conn.Close();
}
return dt;
}
#endregion
}

//前台页面中的绑定flower方法
protected void bindflower()
{
if (Request.QueryString["id"] != null)
{
string flowerid = Request.QueryString["id"].ToString();
MyFlower.Flower flower = new Flower.MyFlower.Flower(flowerid);
labName.Text = flower.FlowerName;
labNO.Text = flower.FlowerBh;
labP1.Text = flower.Price;
labP2.Text = flower.MemberPrice;
labBaozhuang.Text = flower.FlowerPack;
Image1.ImageUrl = flower.FlowerPic;
liter_detail.Text = flower.Description;
}
}

这是一个查看某一鲜花的操作。请参考
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式