我有 2 张桌子。我想从 Table1 中获取所有 ID,当我在第一个 OleDbCommand 中时,我想检查 ID 是否也在 Table2 中。我试过这个:
using (OleDbCommand cmd = new OleDbCommand("SELECT ID FROM Table1 WHERE NAME=:NAME)
{
............
decimal dId = (decimal)odr["ID"];
using (OleDbCommand cmdE = new OleDbCommand("SELECT LOGID FROM Table2 WHERE ID:=ID", con))
cmdE.CommandType = CommandType.Text;
cmdE.Parameters.Add(new OleDbParameter("ID", dId));
decimal cId=-1;
using (OleDbDataReader odrE = cmdE.ExecuteReader())
{
while (odrE.Read())
{
cId = (decimal)odrE["ID"];
}...............
问题是
cId = (decimal)odrE["ID"];
永远不会执行,即使我在 Sql Developer 中执行手动选择,我也会得到结果。我究竟做错了什么?