数据查询问题! strSQL="select * from user where login_name='"+strName+"'and login_pwd='"+strPassword+"'";其中user表中有用户部门,我现在想把取得其部门的值,然后用chche传递到其他的页面。取值我总是不成功,请高手指教! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 直接取出部门的值将其赋给变量,然后传参到其它页面.chche传递?是cache吧,有必要用cache吗?直接用URL参数也可以进行传递 dim departmentID as integer=ds.tables(0).rows(0)("deptID")dim urlstr as string="main.aspx?deptid=" & departmentIDresponse.redirect(urlstr) string department="";SqlCommand cmd=new SqlCommand(strSQL,ConnectionString);SqlDataReader dr=cmd.ExecuteReader ();if(dr.Read()){ department=dr["部门字段"];}dr.Close();if(department!=""){ //取出来了,处理..........} 无法将类型“object”隐式转换为“string 我的想法是把部门传给下一个页面aa.aspx,在aa.aspx中可利用所传来的部门进行对另外一张表的查询。用户表中的部门在另一张表中有的没有! 比如管理员,在另一张表中就没有! string department="";SqlCommand cmd=new SqlCommand(strSQL,ConnectionString);SqlDataReader dr=cmd.ExecuteReader ();if(dr.Read()){ department=dr["部门字段"].ToString();}dr.Close();if(department!=""){ //取出来了,处理..........} 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"]+"' |zyciis| C#4.0传说中的新特性:安全的null延迟赋值操作符,但真实出来没有,那我们如何来实现这个功能呢?有点变态 谢谢 怎么给gridview 加多行脚标题行? 关于页面刷新和页面回发 关于asp.net的问题,,请高手指点一下 用ASP调用DLL创建object,服务器本机用localhost可以运行,使用IP返回CreateObject Exception 邮件接收应该怎么做?请各位高手指点哈! 困难的产品字段显示?我该怎么办 求解页面不刷新 IHttpModule 里面怎么向请求页面写JS脚本?? 关于STATE的运用问题 急!!!! 一个按钮的小问题 一个ajax的问题
是cache吧,有必要用cache吗?直接用URL参数也可以进行传递
dim urlstr as string="main.aspx?deptid=" & departmentID
response.redirect(urlstr)
SqlCommand cmd=new SqlCommand(strSQL,ConnectionString);
SqlDataReader dr=cmd.ExecuteReader ();
if(dr.Read())
{
department=dr["部门字段"];
}
dr.Close();
if(department!="")
{
//取出来了,处理..........
}
SqlCommand cmd=new SqlCommand(strSQL,ConnectionString);
SqlDataReader dr=cmd.ExecuteReader ();
if(dr.Read())
{
department=dr["部门字段"].ToString();
}
dr.Close();
if(department!="")
{
//取出来了,处理..........
}
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"]+"'