0
我正在使用linq從數據庫中刪除數據。我搜索了一下,並進行了查詢。我正在使用以下查詢。刪除查詢不起作用
當我把調試器放在這裏,它沒有顯示任何錯誤。它會很好。但是當我檢查我的數據庫時,記錄不會被刪除。
同時做操作插入:
splitTradeDataContext db = new splitTradeDataContext();
tradeFile tlbTradeFile = new tradeFile();
tlbTradeFile.TradeNo = TradeNo + "_A";
tlbTradeFile.Status = Status;
tlbTradeFile.Scrip_Code = Scrip_Code;
tlbTradeFile.Inst_Type = Inst_Type;
tlbTradeFile.Expirydate = Expirydate;
tlbTradeFile.Strike_price = Strike_price;
tlbTradeFile.Option_type = Option_type;
tlbTradeFile.Sec_Name = Sec_Name;
tlbTradeFile.BookType = BookType;
tlbTradeFile.BookTypeName = BookTypeName;
tlbTradeFile.TerminalId = TerminalId;
tlbTradeFile.Branch_Id = Branch_Id;
tlbTradeFile.Buy_Sell = Buy_Sell;
tlbTradeFile.Trade_Qty = Trade_Qty;
tlbTradeFile.Market_Rate = Market_Rate;
tlbTradeFile.Pro_cli = Pro_cli;
tlbTradeFile.Party_Code = Party_Code + "_A";
tlbTradeFile.ParticipantCode = ParticipantCode;
tlbTradeFile.O_C_Flag = O_C_Flag;
tlbTradeFile.Sauda_Date = Sauda_Date;
tlbTradeFile.TradeModified = TradeModified;
tlbTradeFile.OrderNo = OrderNo;
tlbTradeFile.Opp_Broker_Id = Opp_Broker_Id;
tlbTradeFile.OrderTime = OrderTime;
tlbTradeFile.UnknowkNum = UnknowkNum;
var remove = from aremove in db.tradeFiles
where aremove.ID==int.Parse(gvTradeFile.SelectedRows[0].Cells[0].Value.ToString())
select aremove;
if(remove!=null)
db.tradeFiles.DeleteAllOnSubmit(remove);
可以採取什麼問題?我使用錯誤的查詢嗎?或者還有什麼東西仍然從我身上?
等待,讓我查 – Freelancer 2013-03-07 12:19:49
db.SubmitChanges()函數是存在的。沒有找到db.SaveChanges(); – Freelancer 2013-03-07 12:20:53
@freelancer,你可能使用LINQ to SQL,你應該調用'db.SubmitChanges',它應該可以完成 – Habib 2013-03-07 12:22:01