Exemple #1
0
 //往数据库中添加赛事,并且返回新被添加的赛事
 public static SeasonMatch addNewMatch(string name,string description,int switchNum,int serialNum)
 {
     SeasonMatch match = new SeasonMatch();
     DBUtility dbutility = new DBUtility();
     int matchID;
     string SQL = "insert into matchinfo(seasonName,description,switchNum,serialNum) values('";
     SQL=SQL+name + "','" + description + "'," + switchNum + "," + serialNum + ")";
     try
     {
         dbutility.openConnection();
         matchID = dbutility.ExecuteQuery_Last_Insert_ID(SQL);
        // dbutility.ExecuteUpdate(SQL);
         match.setID(matchID);
         match.setName(name);
         match.setDescription(description);
         match.setSwitchNum(switchNum);
         match.setSerialNum(serialNum);
     }
     catch (MySqlException ex)
     {
         Console.WriteLine(ex.ToString());
     }
     finally
     {
         dbutility.Close();
     }
     return match;
 }