strSQL="select * from user where login_name='"+strName+"'and login_pwd='"+strPassword+"'";其中user表中有用户部门,我现在想把取得其部门的值,然后用chche传递到其他的页面。取值我总是不成功,请高手指教!

解决方案 »

  1.   

    直接取出部门的值将其赋给变量,然后传参到其它页面.chche传递?
    是cache吧,有必要用cache吗?直接用URL参数也可以进行传递
      

  2.   

    dim departmentID as integer=ds.tables(0).rows(0)("deptID")
    dim urlstr as string="main.aspx?deptid=" & departmentID
    response.redirect(urlstr)
      

  3.   

    string department="";
    SqlCommand cmd=new SqlCommand(strSQL,ConnectionString);
    SqlDataReader dr=cmd.ExecuteReader ();
    if(dr.Read())
    {
       department=dr["部门字段"];
    }
    dr.Close();
    if(department!="")
    {
       //取出来了,处理..........
    }
      

  4.   

    无法将类型“object”隐式转换为“string
      

  5.   

    我的想法是把部门传给下一个页面aa.aspx,在aa.aspx中可利用所传来的部门进行对另外一张表的查询。用户表中的部门在另一张表中有的没有! 比如管理员,在另一张表中就没有!
      

  6.   

    string department="";
    SqlCommand cmd=new SqlCommand(strSQL,ConnectionString);
    SqlDataReader dr=cmd.ExecuteReader ();
    if(dr.Read())
    {
       department=dr["部门字段"].ToString();
    }
    dr.Close();
    if(department!="")
    {
       //取出来了,处理..........
    }
      

  7.   

    SqlConnection sqlconn=new SqlConnection(ConnectionString);
    string ssql="select * from user where login_name='"+strName+"'and login_pwd='"+strPassword+"'";
    SqlCommand sqlcmd=new SqlCommand(ssql,sqlconn);
    sqlconn.open();
    SqlDataReader dr=sqlcmd.ExecuteReader();
    while(dr.Read())
    {
        this.Session["department"]=dr["部门字段"].ToString();
    }
    sqlconn.close();在另一个页面调用就直接在sql语句里写where 字段='"+this.Session["department"]+"'