Пример #1
0
        public bool insertintomp(mdetails p)
        {
            bool          isSuccess = false;
            SqlConnection conn      = new SqlConnection(myconnstrng);

            try
            {
                String     sql = "INSERT INTO mp values(@masterpassword)";
                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@masterpassword", p.masterpassword);

                conn.Open();

                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }
Пример #2
0
        public bool verify(mdetails p)
        {
            bool          okay = false;
            SqlConnection conn = new SqlConnection(myconnstrng);

            try
            {
                string     query = "select masterpassword from mp where masterpassword = @masterpassword";
                SqlCommand cmd   = new SqlCommand(query, conn);
                cmd.Parameters.AddWithValue("@masterpassword", p.masterpassword);
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                conn.Open();


                DataTable dt = new DataTable();
                adapter.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    okay = true;
                }
                else
                {
                    okay = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(okay);
        }