想在gridview中直接显示登录时传过来用户名所在那行的所有信息表,怎么实现呀?

来源:百度知道 编辑:UC知道 时间:2024/06/07 13:36:16
表名为《个人信息》
其主要是session的用法和SQL查询语句的编写
哪位高手帮忙解决一下,谢谢了!!
紧急中.......

protected void dataGridBind()
{
SqlConnection conn = DB.Connection;
SqlCommand cmd = new SqlCommand();
if (Convert.ToString(Session["name"])!="")
{
string name= int.Parse(Request.QueryString["name"]);
string str= "select * from 表where 用户名=" + name + " ;
SqlDataAdapter sda = new SqlDataAdapter(str, conn);
DataSet ds = new DataSet();
sda.Fill(ds, "表");
this.GridView1.DataSource = ds;
//this.GridView1.DataKeyNames = new string[] { "表主键" };//主键
this.GridView1.DataBind();
}

string loginName = tbLoginName.Text.Trim();
DataTable user = SqlHelper.ExcuteDataTable("SELECT * FROM 个人信息 WHERE 用户名='"+loginName+"'");
this.gridview.DataSource = reader;