我正在尝试代码,但它不工作显示错误 [英] i am trying the code but it is not working shows error
问题描述
使用会话传递数据库值并重定向到另一个页面。
我的代码如下;
passing the database value using session and redirect to another page.
My code as follows;
SQl = "Select Bthid from startexec";
Dr = SCon.ReadSql(SQl);
BthID = Convert.ToInt64(TxtBthNo.Text.ToString().Trim());
Session["Bthid"] = BthID;
Response.Redirect("Instruction.aspx");
当我尝试以下代码时显示错误如下;
when i try the below code shows error as follows;
Input string was not in correct format.
上面的代码有什么问题?
数据库Bthid数据类型是bigint 。
请帮帮我。
问候,
narasiman P
what is the problem in my above code?
in database Bthid datatype is bigint.
please help me.
Regards,
narasiman P
推荐答案
BthID = Convert.ToInt64(TxtBthNo.Text.ToString().Trim());
此时 TxtBthNo
的实际内容是多少?此外,您不需要在 Text
项目上使用 ToString()
方法;事实上,这可能是它失败的原因,请尝试:
What is the actual conent of TxtBthNo
at this point? Also, you do not need to use the ToString()
method on a Text
item; in fact that may be why it is failing, try:
string strBthId = TxtBthNo.Text.Trim();
BthID = Convert.ToInt64(strBthId);
以这种方式调试应该更容易。
It should be easier to debug that way.
这篇关于我正在尝试代码,但它不工作显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!