Today, Liu was checking the program I wrote and found that I had made a very low-level mistake. Write today and warn yourself not to make the same mistake again ...
When the shift is added, this deadlock situation is encountered. When I added the shift, I didn't look closely at the code in the Dal. Just one-sided look at the addition of the method, so that made a very low-level error. To prevent errors.
You can take two scenarios:
1, first do not deadlock, choose to see can be added correctly after the deadlock.
2. Directly query the data in the database after adding. When adding or editing, be sure to go to the library to check. This is the most direct and effective method.
Remember not to make the same mistake again .....
#region Initialization Parameters
<summary>
Initialize parameters
</summary>
<returns>System.Collections.ArrayList</returns>
Private ArrayList initlizeparames (ClassInfo ci, dataoperationtype type)
{
ArrayList parames = new ArrayList ();
Delete
if (type = = Dataoperationtype.del)
{
Exidbdataparameter parame1 = new Exidbdataparameter ("COLUMN1", Dbtype.int64, Ci. ID);
Parames. ADD (PARAME1);
return parames;
}
Modify
if (type = = Dataoperationtype.update)
{
Exidbdataparameter parame1 = new Exidbdataparameter ("COLUMN1", Dbtype.int64, Ci. ID);
Parames. ADD (PARAME1);
}
Modify, add
Parames. ADD (PARAME17);
Exidbdataparameter Parame24 = new Exidbdataparameter ("COLUMN24", Dbtype.datetime, Ci. Editzzdate);
Parames. ADD (PARAME24);
Exidbdataparameter parame25 = new Exidbdataparameter ("COLUMN25", Dbtype.datetime, Ci. Editzzenddate);
Parames. ADD (PARAME25);
Exidbdataparameter parame26 = new Exidbdataparameter ("COLUMN26", Dbtype.int32, Ci. Classchushi);//Record of the Virgin Room, at that time there is a default value.
Parames. ADD (PARAME26);
Exidbdataparameter Parame27 = new Exidbdataparameter ("COLUMN27", Dbtype.int32, Ci. Classjxstate);
Parames. ADD (PARAME31);
Parames. ADD (PARAME38);
return parames;
}
#endregion Initialization Parameters
#region Add a class
<summary>
Add class information, return ID
</summary>
<param name= "CI" >jw. Module.classinfo Object </param>
<returns> successful return ID, failed to return 0</returns>
public int addclassinfo (ClassInfo ci)
{
int id = 0;
String strSQL = "INSERT into Table2 ("
+ "Column2,column3,column4,column5,column6,column7,column8,column9,column10,column11,column12,column13,column14 , Column15,column16,column17,column18, "
+ "Column19,column20,column21,column22,column23,column24,column25,column26,column27,column28,column29,column30, Column31,column32,column33,column34, "
+ "column35,column36,column37,column38)"
+ "VALUES" ("
+ "@COLUMN2, @COLUMN3, @COLUMN4, @COLUMN5, @COLUMN6, @COLUMN7, @COLUMN8, @COLUMN9, @COLUMN10, @COLUMN11, @COLUMN12, @ COLUMN13, @COLUMN14, @COLUMN15, @COLUMN16, "
+ "@COLUMN17, @COLUMN18, @COLUMN19, @COLUMN20, @COLUMN21, @COLUMN22, @COLUMN23, @COLUMN24, @COLUMN25, @COLUMN26, @ COLUMN27, @COLUMN28, @COLUMN29, @COLUMN30, "
+ "@COLUMN31, @COLUMN32, @COLUMN33, @COLUMN34, @COLUMN35, @COLUMN36, @COLUMN37, @COLUMN38) SELECT @ @identity";
ArrayList Parames = this. Initlizeparames (CI, dataoperationtype.add);
Try
{
id = Int. Parse (Datahelper.executescalar (strSQL, CommandType.Text, Parames). ToString ());
}
Catch
{
id = 0;
}
return ID;
}
#endregion Add a class
Sentiment:
1, write what things must first think about how to write, which is prone to error.
2, look at the program must be the overall grasp, do not just look at your own use of the method. We have to take control of the whole.
3, although this error is very small, but very low. I can't underestimate this mistake, I must take this as a ring. Be sure not to make such a mistake again!
4, do not only do the surface of the things you can see, there is a comprehensive look at what you need to this module and where it needs to be.
5, time to the user's identity to experience, think of this thing after you use. If you do well, use it for convenience.
The feeling of getting from the wrong kind of childhood