使用会话传递数据库值并重定向到另一个页面 [英] passing the database value using session and redirect to another page

查看:69
本文介绍了使用会话传递数据库值并重定向到另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码如下;





SQl =从startexec中选择Bthid;

Dr = SCon.ReadSql(SQl);

string Bthid = Convert.ToInt16(Session [BthID]。ToString());

Response.Redirect(Instruction.aspx );



在数据库中Bthid数据类型是bigint



当我运行时显示错误如下



无法将类型''short''隐式转换为''string''





我该怎么办?

解决方案

而不是字符串Bthid = Convert.ToInt16(Session [BthID]。ToString());



使用这个:



Int16 Bthid = Convert.ToInt16(Session [BthID]。ToString( ));



或者这个



字符串Bthid = Session [BthID]。ToString() ;

code as follows;


SQl = "Select Bthid from startexec";
Dr = SCon.ReadSql(SQl);
string Bthid = Convert.ToInt16(Session["BthID"].ToString());
Response.Redirect("Instruction.aspx");

In database Bthid datatype is bigint

when i run shows error as follows

Cannot implicitly convert type ''short'' to ''string''


for that how can i do?

解决方案

instead of string Bthid = Convert.ToInt16(Session["BthID"].ToString());

use either this:

Int16 Bthid = Convert.ToInt16(Session["BthID"].ToString());

or this

string Bthid = Session["BthID"].ToString();


这篇关于使用会话传递数据库值并重定向到另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆