示例#1
0
        public List <UsersLocale> get_User_Locale(string email)
        {
            List <UsersLocale> list_of_user_locale = new List <UsersLocale>();
            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 UsersLocale where UsersLocale.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())
                {
                    UsersLocale ul = new UsersLocale();

                    ul.Locale = (string)dr["Locale"];
                    ul.Email  = (string)dr["Email"];
                    ul.Id     = (string)dr["Id"];



                    list_of_user_locale.Add(ul);
                }
                return(list_of_user_locale);
            }
            catch (Exception ex)
            {
                // write to log
                throw (ex);
            }
            finally
            {
                if (con != null)
                {
                    con.Close();
                }
            }
        }
示例#2
0
        public List <UsersLocale> Get(string email)
        {
            UsersLocale u = new UsersLocale();

            return(u.get_User_Locale(email));
        }