【发布时间】:2009-07-27 16:31:56
【问题描述】:
您之前回答我的其他问题非常出色 - 所以我又来了,需要一些帮助!
我有一个查询,它连接三个表和一个强类型数据集,其中包含为从查询返回的所有内容定义的列。当我去填充数据适配器时,什么都没有填充。我已经从另一种方法中复制了代码,所以我认为没问题 - 唯一的区别是这个查询有连接。任何帮助表示赞赏,代码如下:
查询:
select gsh.locid, locations.description, GSH.workorder, GSH.comstatus, GSH.teststatus, GSH.fireresult, GSH.lightresult, GSH.watercold, GSH.waterhot, GSH.responsedate, GSH.comments, GSH.testername
from gsh_vhs_locations locs
left outer join locations on locs.maximoloc = locations.location
left outer join gsh_vhs_comms GSH on locs.LOCID = GSH.locid
where gsh.insertdate > sysdate-7
order by locid, locations.description, GSH.workorder, GSH.comstatus, GSH.teststatus, GSH.fireresult, GSH.lightresult, GSH.watercold, GSH.waterhot, GSH.responsedate, GSH.comments, GSH.testername
代码:
ResponseSheet Tests = new ResponseSheet();
DataSet ReturData = new DataSet();
OracleDataAdapter da;
try
{
using (OracleConnection conn = new OracleConnection(ConnString))
{
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = @"select gsh.locid, locations.description, GSH.workorder, GSH.comstatus, GSH.teststatus, GSH.fireresult, GSH.lightresult, GSH.watercold, GSH.waterhot, GSH.responsedate, GSH.comments, GSH.testername
from gsh_vhs_locations locs
left outer join locations on locs.maximoloc = locations.location
left outer join gsh_vhs_comms GSH on locs.LOCID = GSH.locid
where gsh.insertdate > sysdate-7
order by locid, locations.description, GSH.workorder, GSH.comstatus, GSH.teststatus, GSH.fireresult, GSH.lightresult, GSH.watercold, GSH.waterhot, GSH.responsedate, GSH.comments, GSH.testername ";
da = new OracleDataAdapter(cmd.CommandText, conn);
da.MissingMappingAction = MissingMappingAction.Error;
da.TableMappings.Add("Table", "ResponseSheet");
da.Fill(ReturData, "ResponseSheet");
}
}
catch (Exception ex)
{
Console.WriteLine(TimeStamp() + ex.Message.ToString() + "Get Capture Report (TraceCode: 00019)");
}
return ReturData;
}
如您所见,我已打开表映射的错误报告,但在运行时我没有收到任何错误,只是一个空数据集 (da = null)
任何你能帮到伙计的事情,如果需要的话,只需在我身上随意戳一下谷歌短语 - 谢谢 :)
加雷斯
【问题讨论】:
-
您已经验证查询确实返回了数据,是吗?
-
是的,我在 toad 中运行它,它会取回我需要的东西。不过好点,你让我去检查!
-
为了确保一切正常,最好运行 cmd.ExecuteNonQuery 并检查返回值以确保正在读取行。
标签: c# .net oracle strongly-typed-dataset tableadapter