一个linq的问题(小弟初学希望大家指教)
DataClasses1DataContext dataaccess = new DataClasses1DataContext();
message messageEntity1 = new message();
message messageEntity2 = new message();
messageEntity1.SIM = i.SIM;
messageEntity1.messagetime = sendtime;
messageEntity1.messagecontent = daymessagetemplate;
messageEntity1.consolenum = "设备号1";
messageEntity2.SIM = i.SIM;
messageEntity2.messagetime = sendtime;
messageEntity2.messagecontent = hourmessagetemplate;
messageEntity2.consolenum = "设备号1";
try
{
dataaccess.messages.InsertOnSubmit(messageEntity1);
dataaccess.messages.InsertOnSubmit(messageEntity2);
dataaccess.SubmitChanges();
}
catch (Exception ex)
{
}
ex = {"此 SqlTransaction 已完成;它再也无法使用。"}
------解决方案--------------------看不明白,你把相关的代码都贴出来啊
------解决方案--------------------
------解决方案--------------------hourmessagetemplate = hourmessagetemplate.Replace("DevID", deviceID).Replace("Rate", rate.ToString()).Replace("F01", F1.ToString()).Replace("F02", F2.ToString()).Replace("F03", F3.ToString()).Replace("F04", F4.ToString()).Replace("F05", F5.ToString()).Replace("F06", F6.ToString()).Replace("F07", F7.ToString()).Replace("F08", F8.ToString()).Replace("F09", F9.ToString()).Replace("F10", F10.ToString()).Replace("F11",F11.ToString()).Replace("F12",F12.ToString());
好疯狂的代码
------解决方案-------------------- dataaccess.messages.InsertOnSubmit(messageEntity1);
//dataaccess.messages.InsertOnSubmit(messageEntity2);
try
{
dataaccess.SubmitChanges();
}
catch (Exception ex)
{
}
是不是一次只能提交一个对象啊。
------解决方案--------------------本身没有问题,可能是你在别的地方用了