The object reference is not set To the instance of the object in Linq To SQL.
We encapsulate public void Delete (T entity) {db in DAL. getTable <T> (). deleteOnSubmit (entity); db. submitChanges () ;}delete public void Delete (stuInfo StuInfo) {db. delete (stuInfo);} this statement is a previously inserted StuInfo stuinfo = new StuInfo {StuAge = 18, StuNo = "s25900", StuSex = "male", StuSeat = 10, stuName = "", ClassID = 1}; stuInServicecs. remoevStuInfo (stuinfo); when we delete stuinfo, we will encounter the following problem: we have not set the object reference to the instance of the object: although this statement It already exists in the database, but it is still in the Free State when processing the stuinfo object. Therefore, you need to query stuinfo = stuInServicecs. GetByStuNo ("s25900") from the database using the primary key of stuinfo and then delete stuinfo.
But I feel a little redundant. I hope there are better solutions.
Linq to xml does not set the object reference to the instance of the object
If the object you are using is null, you may find that there is null in the case of your error. Please debug it in detail.
Hook. Lamda ~~ Yes ~
When you connect to the database through LINQ, the object reference is not set to the instance of the object.
It doesn't matter if the value of wealth is zero. Here we will discuss how to help each other ~
OrderID = Session ["userName"]. ToString (),
Your code needs to pass the value above. When you run this page, the system does not pass the value of Session ["userName"], and the system considers that you have not referenced the object as an instance.