// getdiv()"SELECT * FROM [NCAAUniversities]"; public List <UsersStates> get_User_States(string email) { List <UsersStates> list_of_user_States = new List <UsersStates>(); SqlConnection con = null; try { con = connect("DBConnectionString"); // create a connection to the database using the connection String defined in the web config file String selectSTR = "SELECT * FROM UsersStates where UsersStates.Email='" + email + "'"; SqlCommand cmd = new SqlCommand(selectSTR, con); // get a reader SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); // CommandBehavior.CloseConnection: the connection will be closed after reading has reached the end while (dr.Read()) { UsersStates us = new UsersStates(); us.States = (string)dr["States"]; us.Email = (string)dr["Email"]; us.Id = Convert.ToInt32(dr["Id"]); list_of_user_States.Add(us); } return(list_of_user_States); } catch (Exception ex) { // write to log throw (ex); } finally { if (con != null) { con.Close(); } } }
public int Post(List <UsersStates> us) { UsersStates usersstates = new UsersStates(); return(usersstates.Insert_arr_states(us)); }
public List <UsersStates> Get(string email) { UsersStates u = new UsersStates(); return(u.get_User_States(email)); }