Exemple #1
0
        public void editRecord(Account Acc)
        {
            //int id;
            openConnectionDb();
            SQLiteCommand cmd = new SQLiteCommand(@"UPDATE tbl_passwords SET email = @em, password = @pw, note = @nt WHERE resource_name = @rn AND login = @lg AND del = 0", connection);
            //SQLiteDataReader reader = cmd.ExecuteReader();
            SQLiteParameter param = new SQLiteParameter();
            param.ParameterName = "@rn";
            param.Value = Acc.getWebName();
            cmd.Parameters.Add(param);

            param = new SQLiteParameter();
            param.ParameterName = "@lg";
            param.Value = Acc.getNameAccount();
            //param.SqlDbType = SqlDbType.Text;
            cmd.Parameters.Add(param);

            param = new SQLiteParameter();
            param.ParameterName = "@em";
            param.Value = Acc.getEmail();
            //param.SqlDbType = SqlDbType.Text;
            cmd.Parameters.Add(param);

            param = new SQLiteParameter();
            param.ParameterName = "@pw";
            param.Value = Acc.getPasswordCr();
            //param.SqlDbType = SqlDbType.Text;
            cmd.Parameters.Add(param);

            param = new SQLiteParameter();
            param.ParameterName = "@nt";
            param.Value = Acc.getNote();
            //param.SqlDbType = SqlDbType.Text;
            cmd.Parameters.Add(param);
            //id = reader;

            //SQLiteCommand cmd = new SQLiteCommand(@"UPDATE tBl_passwords SET resource_name = @rn, login = @lg, email = @em, password = @pw, note = @nt, del = 0", connection);
            //SqlParameter param = new SqlParameter();

            try
                {
                    cmd.ExecuteNonQuery();
                }
            catch
            {
                Console.WriteLine("Ошибка, при выполнении запроса на изменение записи");
               return;
            }
        }
Exemple #2
0
        //(string rn, string lg, string em, string pw, string nt)
        public void newRecord(Account Acc)
        {
            //connection = new SQLiteConnection(string.Format("Data Source={0};", dbName));
            //connection.Open();
            openConnectionDb();

            SQLiteCommand cmd = new SQLiteCommand(@"INSERT INTO tbl_passwords (resource_name, login, email, password, note, del) values (@rn, @lg, @em, @pw, @nt, 0)", connection);

            SQLiteParameter param = new SQLiteParameter();
            param.ParameterName = "@rn";
            param.Value = Acc.getWebName();
            cmd.Parameters.Add(param);

            param = new SQLiteParameter();
            param.ParameterName = "@lg";
            param.Value = Acc.getNameAccount();
            //param.SqlDbType = SqlDbType.Text;
            cmd.Parameters.Add(param);

            param = new SQLiteParameter();
            param.ParameterName = "@em";
            param.Value = Acc.getEmail();
            //param.SqlDbType = SqlDbType.Text;
            cmd.Parameters.Add(param);

            param = new SQLiteParameter();
            param.ParameterName = "@pw";
            param.Value = Acc.getPasswordCr();
            //param.SqlDbType = SqlDbType.Text;
            cmd.Parameters.Add(param);

            param = new SQLiteParameter();
            param.ParameterName = "@nt";
            param.Value = Acc.getNote();
            //param.SqlDbType = SqlDbType.Text;
            cmd.Parameters.Add(param);

            try
                {
                    cmd.ExecuteNonQuery();
                }
            catch
            {
                Console.WriteLine("Ошибка, при выполнении запроса на добавление записи");
                return;
            }
            connection.Close();
        }