您之前在其他问题上表现出色,因此在这里我再次需要帮助!
我有一个查询,该查询连接了三个表和一个强类型的数据集,该数据集具有为从查询返回的所有内容定义的列。当我去填充数据适配器时,什么也不会被填充。我已经从另一种方法复制了代码,所以我认为这没问题-唯一的区别是此查询具有联接。任何帮助表示赞赏,代码如下:
查询:select gsh.locid, locations.description, GSH.workorder, GSH.comstatus, GSH.teststatus, GSH.fireresult, GSH.lightresult, GSH.watercold, GSH.waterhot, GSH.responsedate, GSH.comments, GSH.testernamefrom gsh_vhs_locations locsleft outer join locations on locs.maximoloc = locations.locationleft outer join gsh_vhs_comms GSH on locs.LOCID = GSH.locidwhere gsh.insertdate > sysdate-7order 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)
你们有什么可以帮助的,如果需要的话,只给我戳随机的Google短语-谢谢:)
加雷斯
最佳答案
尝试处理OnFillError事件。我不确定是否会有所帮助,但是值得一试。
关于c# - 强类型数据集不会填充,表映射有问题吗? C#.net 2.0,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1189219/