示例#1
0
        public bool checkDuplicateAccount(string username)
        {
            bool          Successful = false;
            SqlConnection cnn        = DBUtils.GetConnection();

            try {
                string SQL = "select *  from  Account where username = @username";



                if (cnn.State == ConnectionState.Closed)
                {
                    cnn.Open();
                }

                SqlCommand cmd = new SqlCommand(SQL, cnn);
                cmd.Parameters.AddWithValue("@username", username);



                Console.Write(cmd);
                SqlDataReader rdr = cmd.ExecuteReader();
                if (rdr.HasRows)
                {
                    Successful = true;
                }
            } catch (Exception e) {
                Console.WriteLine(e);
                throw;
            } finally {
                cnn.Close();
            }



            return(Successful);
        }