c# – 指定的演员表无效
发布时间:2020-12-15 08:46:46 所属栏目:百科 来源:网络整理
导读:我正在尝试使用以下代码从我的数据库中获取Score_Waarde值: critid = critid_arr[teller2].ToString();int scorehulp = 0;string userid = Session["userid"].ToString();SqlCommand cmd3 = new SqlCommand("SELECT Score_Waarde FROM Score WHERE Crit_ID
我正在尝试使用以下代码从我的数据库中获取Score_Waarde值:
critid = critid_arr[teller2].ToString(); int scorehulp = 0; string userid = Session["userid"].ToString(); SqlCommand cmd3 = new SqlCommand("SELECT Score_Waarde FROM Score WHERE Crit_ID = '" + critid + "' AND User_ID = '" + userid + "' ",con); scorehulp = (int)cmd3.ExecuteScalar(); 当我尝试运行它时,我收到以下错误:指定的强制转换无效. 解决方法
您的SQL可能会返回不同的数字类型,例如long或decimal,或者显然是字符串.
调用Convert.ToInt32,它没有limitations of an unboxing cast. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |