我试图做一个INSERT语句到SQL,但得到以下错误:数据类型不匹配
there's an error data type mismatch in criteria expression
这是我的查询:
string Query = "INSERT INTO [laptop table]
(Name,Serial,Charger,Colour,Notes,Exist)
VALUES
('" + this.nametxt.Text + "','" +
this.serialtxt.Text + "','" +
this.chargertxt.Text + "','" +
this.colourtxt.Text + "','" +
this.notestxt.Text + "','" +
this.Exist.Checked.ToString() + "');";
有谁知道是什么导致这个?
欢迎来到StackOverflow。请阅读[问]和[常见问题]。如果你没有详细说明你的问题是什么,我们将无法帮助你。 – Marco
噢,我的眼睛 - Yu!如果只有代码使用[*占位符*](http://bobby-tables.com/csharp.html),这个问题*甚至不存在*!因此我的建议是使用占位符。检查* actual *字符串值将会显示SQL语法/输入问题,并且可以在SSMS或其他任何地方使用。 – user2864740
'laptop table'的一个属性可能有非文本数据类型。看看'Serial'。 – collapsar