你之前在我的其他问题中表现得非常出色 - 所以我又来求助了!
我有一个查询涉及三个表和一个强类型数据集,该数据集定义了从查询返回的所有列。当我尝试填充数据适配器时,什么都没有填充。我复制了另一个方法的代码,所以我认为它没问题 - 唯一的区别是这个查询涉及联接。如果有任何帮助,以下是代码:
查询语句:
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)。
如果需要,您可以随便向我提供一些谷歌短语,非常感谢您的帮助!
Gareth