"/cloudcomputing"应用程序中的服务器错误.输入的字符串格式不正确. [英] Server Error in '/cloudcomputing' Application. Input string was not in a correct format.

查看:104
本文介绍了"/cloudcomputing"应用程序中的服务器错误.输入的字符串格式不正确.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



任何人都可以通过以下代码解决此错误吗?




Can anyone solve this error in follwing code?


public int get_sig(string id)
   {
       SqlConnection cn = new SqlConnection(ConfigurationSettings.AppSettings["constring"]);
       cn.Open();
       SqlCommand cmd2 = new SqlCommand("select signature from audit", cn);
       SqlDataReader dr2 = cmd2.ExecuteReader();
       while (dr2.Read())
       {

           signature = int.Parse(dr2["signature"].ToString());

       }

       dr2.Close();
       return signature;
   }

推荐答案

当然,当您尝试将非数字或空字符串转换为整数到签名"变量时,会发生此问题.您可以通过将代码放入try..catch clock
来对其进行跟踪.
Surely, this problem occurs when you try to convert non numeric or empty string into integer to ''signature'' variable. You can trace it by putting the code in try..catch clock
try
{
 signature = int.Parse(dr2["signature"].ToString());
}
catch (Exception ex)
{
}


这篇关于"/cloudcomputing"应用程序中的服务器错误.输入的字符串格式不正确.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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