我有以下代码:
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 类型。所以我不知道为什么这会失败。
提前致谢!