我有以下代码:
public void GetParameterSelectionSet(int wire, int bond, string processProgramPath)
{
string connectionString = "Provider=Microsoft.JET.OLEDB.4.0;" + "data source=" + processProgramPath + ";";
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
connection.Open();
using (OleDbCommand command = new OleDbCommand("SELECT * " +
"FROM BONDS INNER JOIN WIRES on " +
"BONDS.WireID = WIRES.WireID " +
"WHERE (WIRES.OperationOrder = '@WireOrder') AND" +
"(BONDS.OperationOrder = '@BondOrder')", connection))
{
command.Parameters.Add(new OleDbParameter("@WireOrder", OleDbType.Numeric));
command.Parameters.Add(new OleDbParameter("@BondOrder", OleDbType.Numeric));
command.Parameters["@WireOrder"].Value = wire;
command.Parameters["@BondOrder"].Value = bond;
var mytemp = command.ExecuteScalar();
}
}
}
当我执行此查询时,我得到“条件表达式中的数据类型不匹配”。
WIRES.OperationOrder和BONDS.OperationOrder都是Numeric类型。所以我很遗憾为什么会失败。
提前致谢!
答案 0 :(得分:5)
您在SELECT语句中的数字参数周围加了引号,这是不正确的。