|
发表于 2008-8-7 17:00:55
|
显示全部楼层
:call:
//显示查询结果的方法~
public static string ExecuteCommand(string safeSql, params SqlParameter[] values)
{
string sql = "";
SqlCommand cmd = new SqlCommand(safeSql, Connection);
cmd.Parameters.AddRange(values);
SqlDataReader reader = cmd.ExecuteReader();
if (reader.Read())
{
sql = reader["title"]+"|||"+reader["images"]+"|||"+reader["content"]; //把数据库里三个字段连接起来
}
return sql;
}
protected void Page_Load(object sender, EventArgs e)
{
string title = Convert.ToString(Request.QueryString["bid"]); //这里是获取页面传递的bid内容,功能跟你那个一样
string safeSql = "select * from titleTest where title title=@title";
this.Label1.Text = Convert.ToString(ExecuteCommand(safeSql, new SqlParameter("title", title))); //调用上面的ExecuteCommand方法~
}
那么就是这样。。。。话说。。;P 我可以拿NM吧~~?
[ 本帖最后由 virgo 于 2008-8-7 17:03 编辑 ] |
|