public void SaveObjectXs()
{
Log.Add("开始触发事件");
string ConnectionString = null;
try
{
XmlDocument doc = new XmlDocument();
doc.Load(AppDomain.CurrentDomain.BaseDirectory + "OESconfig.xml");
XmlNodeList elemlist = doc.GetElementsByTagName("connectionStrings");
ConnectionString = elemlist[2].InnerXml;
}
catch
{
MessageBox.Show("读取XML文件出错,请重试!");
}
var coreAccess = new CoreDataAccess();
var conn = new SqlConnection(ConnectionString);
Log.Add("生成机器上的连接..");
try
{
coreAccess.BeginTransaction();
conn.Open();
var result = new DataTable();
result = GetObjectLastXs();
Log.Add("已经获取到送货单信息,数量" + result.Rows.Count);
Log.Add("开始获取已有对账单");
ICriterion cri = Expression.Like("NextNewDate", "%" + AuxiliaryClass.SyncTime.Substring(0, 7) + "%");
IList<XSDatetils> list = coreAccess.GetObjectList<XSDatetils>(cri, "NextNewDate", false);
if (list != null)
Log.Add("已存在对账单数为:" + list.Count);
else
Log.Add("已存在对账单数为:0");
foreach (DataRow row in result.Rows)
{
var xsDatetils = GetObjectXs(row);
if (!list.Contains(xsDatetils))
{
Log.Add("保存送货单号为" + xsDatetils.OutOrderId + "的对账单");
coreAccess.SaveOrUpdate(xsDatetils);
}
}
coreAccess.Commit();//提交的时候会报异常,An exception occurred when executing bacth queries,意思说我执行的批量查询出现错误。我找了很久,没找到错误..
Log.Add("全部保存完成");
}
catch
{
coreAccess.RollBack();
}
finally
{
conn.Close();
coreAccess.CloseSession();
}
}求大虾帮我看看问题所在... 急啊!! 在线等!!!
An exception occurred when executing bacth queries 这个只是Message,异常原因要看InnerException