简体   繁体   English

有人可以解释此System.ArgumentException错误的意思吗?

[英]Can someone explain what this System.ArgumentException error means?

I have this code: 我有以下代码:

//check if the user have any previous medical record.
var firstMedical = false;
    var sql="SELECT * FROM Medical WHERE CDSID = @0";
    var myMedical = db.QuerySingle(sql1, myCDSID);
    if (myMedical ==null){

                //if all the medical data is filled in, run sql1 to store all the answer into a database.
                var sql10 = "INSERT INTO Medical (Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15, Q16, Q17, Q18, Q19, Q20, Alcohol, Medication, Details, CDSID) VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, @9, @10, @11, @12, @13, @14, @15, @16, @17, @18, @19, @20, @21, @22, @23)";
                var medquestionnaire = new{q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20, alcohol, medication, details, myCDSID};
                db.Execute(sql10, medquestionnaire);

    } else {

                var sql2 = "UPDATE Medical SET Q1=@0, Q2=@1, Q3=@2, Q4=@3, Q5=@4, Q6=@5, Q7=@6, Q8=@7, Q9=@8, Q10=@9, Q11=@10, Q12=@11, Q13=@12, Q14=@13, Q15=@14, Q16=@15, Q17=@16, Q18=@17, Q19=@18, Q20=@19, Alcohol=@20, Medication=@21, Details=@22 WHERE CDSID=@23";
                var updquestionnaire = new{q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20, alcohol, medication, details, myCDSID};
                db.Execute(sql2,updquestionnaire); //error is highlighted on this line.

     }

Error is highlighted on db.Execute(sql2,updquestionnaire); 错误在db.Execute(sql2,updquestionnaire);上突出显示db.Execute(sql2,updquestionnaire); .

Error is: 错误是:

Exception Details: System.ArgumentException
 : No mapping exists from DbType <>f__AnonymousType0`24[System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.String,System.Object]
   to a known SqlCeType.

I do not understand what this error means and Webmatrix does not really explain this error clearly at all. 我不明白此错误的含义,而且Webmatrix根本没有真正清楚地解释此错误。 How should I interpret that error, and fix it? 我应该如何解释该错误并进行修复?

Since db.Execute expects an array of objects as the second parameter try changing your new statement to explicitly create an array of objects. 由于db.Execute希望将对象数组作为第二个参数,因此请尝试更改new语句以显式创建对象数组。 Something like this for example... 像这样的东西...

var updquestionnaire = new object[] {q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20, alcohol, medication, details, myCDSID};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误 System.ArgumentException:“不支持关键字:“字符集”。” - Error System.ArgumentException: "Keyword not supported: "charset"." 发生System.ArgumentException - System.ArgumentException occurred 异常“System.ArgumentException” - exception 'System.ArgumentException' System.ArgumentException:'targetBounds' - System.ArgumentException: 'targetBounds' ImageResizer-转换PSD文件时出错-System.ArgumentException:参数无效 - ImageResizer - Error converting PSD file - System.ArgumentException: Parameter is not valid System.ArgumentException:路径中存在非法字符。 错误 - System.ArgumentException: Illegal characters in path. error System.ArgumentException:编码的字符串只能用于密码 - System.ArgumentException: The encoded string can only be used for a password .Net 错误:System.ArgumentException:&#39;不支持关键字:&#39;trustedconnection&#39;。&#39; - .Net error: System.ArgumentException: 'Keyword not supported: 'trustedconnection'.' Marshal.PtrToStructure抛出System.ArgumentException错误 - Marshal.PtrToStructure throwing System.ArgumentException error System.ArgumentException:&#39;参数无效。 (showDialog错误) - System.ArgumentException: 'Parameter is not valid.' (showDialog error)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM