コード例 #1
0
ファイル: DA_Attempts.cs プロジェクト: hectorhaas/PreCheck
 public List<BM_Attempt> returnAllAttemptsToday()
 {
     string query = "SELECT [Id],[secondsamt],[datetimesubmitted] FROM [hectorhaas].[precheckAverageAttempts] WHERE [datetimesubmitted] >= DATEADD(DAY, 0, DATEDIFF(DAY, 0, CURRENT_TIMESTAMP)) AND [datetimesubmitted] < DATEADD(DAY, 1, DATEDIFF(DAY, 0, CURRENT_TIMESTAMP))";
     List<BM_Attempt> attemptList = new List<BM_Attempt>();
     SqlConnection conn = new SqlConnection(DataAccess.connstring);
     //Open Conn
     conn.Open();
     SqlCommand sc = new SqlCommand(query, conn);
     SqlDataReader dr = sc.ExecuteReader();
     //Loop the reader
     if (dr.HasRows)
     {
         while (dr.Read())
         {
             //Create temp object
             BM_Attempt attempt = new BM_Attempt();
             attempt.Id = dr.GetValue(0).ToString();
             attempt.secondsamt = dr.GetValue(1).ToString();
             attempt.datetimesubmitted = dr.GetValue(2).ToString();
             //Add to list
             attemptList.Add(attempt);
         }
     }
     //Close Conn
     conn.Close();
     //Return the list and end the method
     return attemptList;
 }
コード例 #2
0
ファイル: DA_Attempts.cs プロジェクト: hectorhaas/PreCheck
 public List<BM_Attempt> returnAllAttempts()
 {
     string query = "SELECT Id, secondsamt, datetimesubmitted FROM hectorhaas.precheckAverageAttempts";
     List<BM_Attempt> attemptList = new List<BM_Attempt>();
     SqlConnection conn = new SqlConnection(DataAccess.connstring);
     //Open Conn
     conn.Open();
     SqlCommand sc = new SqlCommand(query, conn);
     SqlDataReader dr = sc.ExecuteReader();
     //Loop the reader
     if(dr.HasRows)
     {
         while(dr.Read())
         {
             //Create temp object
             BM_Attempt attempt = new BM_Attempt();
             attempt.Id = dr.GetValue(0).ToString();
             attempt.secondsamt = dr.GetValue(1).ToString();
             attempt.datetimesubmitted = dr.GetValue(2).ToString();
             //Add to list
             attemptList.Add(attempt);
         }
     }
     //Close Conn
     conn.Close();
     //Return the list and end the method
     return attemptList;
 }