ASP.NET 新增数据代码能正常使用 但是放在服务器上面 客服使用当中出现所有字段为
异常
System.FormatException: Failed to convert parameter value from a String to a Int32. ---> System.FormatException: Input string was not in a correct format. at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.String.System.IConvertible.ToInt32(IFormatProvider provider) at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType) --- End of inner exception stack trace --- at System.Data.SqlClient.SqlParameter.CoerceValue(Object value, MetaType destinationType) at System.Data.SqlClient.SqlParameter.GetCoercedValue() at System.Data.SqlClient.SqlParameter.Validate(Int32 index, Boolean isCommandProc) at System.Data.SqlClient.SqlCommand.BuildParamList(TdsParser parser, SqlParameterCollection parameters) at System.Data.SqlClient.SqlCommand.BuildExecuteSql(CommandBehavior behavior, String commandText, SqlParameterCollection parameters, _SqlRPC& rpc) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at ZWL.DBUtility.DbHelperSQL.ExecuteSql(String SQLString, SqlParameter[] cmdParms) in D:\RABFX\资源文件\OA系统\sngerp\代码\DBUtility\DbHelperSQL.cs:line 535 at ZWL.BLL.BC_Program.AddProgram(C_Program ca) at Talent_bmym_Registration.AddJmxx(String Programname, String Instructor, String Contact, String Musicalinstruments, String ProgramNeir, String renshu, String hidden4, String hidden5, String hidden3) in e:\sngpay\Talent\bmym\Registration.aspx.cs:line 304
取值JS代码
function showBgaa() {
var ty = document.getElementById("ty");
var btnYS = document.getElementById("btnYS");
var btnDD = document.getElementById("btnDD");
var btnBY = document.getElementById("btnBY");
var btnNL = document.getElementById("btnNL");
if (btnYS.value == "选择/修改" || btnDD.value == "选择/修改" || btnBY.value == "选择/修改" || btnNL.value == "选择/修改") {
alert("请完善资料后报名");
return;
}
var btnYSa = document.getElementById("btnYSa");
var btnDDa = document.getElementById("btnDDa");
var btnBYa = document.getElementById("btnBYa");
var btnNLa = document.getElementById("btnNLa");
var hidden = document.getElementById("hidden");
if (ty.checked == true) {
window.location.href = "ByZclist.aspx?Boundaryid=" + hidden.value + "&Stadiumid=" + btnDDa.value + "&Categoryid=" + btnBYa.value + "&Agegroupid=" + btnNLa.value + "&ysleibie=" + btnYSa.value + "";
} else {
alert("请认真阅读报名简章");
}
}
后台接收代码
List<string> list = new List<string>();
try
{
//Boundaryid=3,Stadiumid=2,Categoryid=5,Agegroupid=1,ysleibie=2
list.Add(Request.QueryString["Boundaryid"].ToString());
list.Add(Request.QueryString["Stadiumid"].ToString());
list.Add(Request.QueryString["Categoryid"].ToString());
list.Add(Request.QueryString["Agegroupid"].ToString());
list.Add(Request.QueryString["ysleibie"].ToString());
Session["C_BoundaryAllow"] = list;
return list;
}
catch (Exception ex) {
ZWL.BLL.ERP_LogUser.WriteLog("SUN", ex.ToString());
return list;
}
异常写的很清楚:Registration.aspx.cs:line 304 报错,原因是尝试把一个string转成int时出错,是不是这个页面有某个字段,本来是期望用户填数字的,结果填的是其他东西。
不不起明 是什么意思
异常写的很清楚:Registration.aspx.cs:line 304 报错,原因是尝试把一个string转成int时出错,是不是这个页面有某个字段,本来是期望用户填数字的,结果填的是其他东西。
你好 正常情况能取到值但是在 特殊情况下面 不能
@落幕残情: 是否是数据有时候返回的是可以转换为int型 有的时候不能转换为int,建议楼主,加断点多测试几次