예제 #1
0
 public void FillData()
 {
     try
     {
         string        connString = ConfigurationManager.ConnectionStrings["connect"].ConnectionString;
         SqlConnection conn       = new SqlConnection(connString);
         conn.Open();
         SqlCommand command = conn.CreateCommand();
         command.CommandType = System.Data.CommandType.Text;
         command.CommandText = "select * from Bets";
         SqlDataReader rd = command.ExecuteReader();
         while (rd.Read())
         {
             Bets bet = new Bets(Convert.ToInt32(rd["Id"].ToString().TrimEnd()), rd["BetName"].ToString().TrimEnd(), rd["Category"].ToString().TrimEnd(), Convert.ToDateTime(rd["Date"].ToString().TrimEnd()), Convert.ToInt32(rd["Coefficient"].ToString().TrimEnd()), rd["SubmitorName"].ToString().TrimEnd());
             bets.Add(bet);
         }
         conn.Close();
     }
     catch (SqlException e) { e.ToString(); }
 }
예제 #2
0
 public void FillData()
 {
     try
     {
         string        connString = ConfigurationManager.ConnectionStrings["connect"].ConnectionString;
         SqlConnection conn       = new SqlConnection(connString);
         conn.Open();
         SqlCommand command = conn.CreateCommand();
         command.CommandType = System.Data.CommandType.Text;
         command.CommandText = "select * from Bets";
         SqlDataReader rd = command.ExecuteReader();
         while (rd.Read())
         {
             Bets bet = new Bets(Convert.ToInt32(rd[0].ToString().TrimEnd()), rd[1].ToString().TrimEnd(), rd[2].ToString().TrimEnd(), Convert.ToDateTime(rd[3].ToString().TrimEnd()), Convert.ToDouble(rd[4].ToString().TrimEnd()), rd[5].ToString().TrimEnd());
             if (bet.Date < DateTime.Today)
             {
                 bets.Add(bet);
             }
         }
         conn.Close();
     }
     catch (SqlException e) { e.ToString(); }
 }