Ejemplo n.º 1
0
        public void insertEntry(string fName, string lName, string permissionsLevel, string id, Bitmap imageBmp, NLTemplate template, string vidLoc)
        {
            OleDbConnection myDbConnection = new OleDbConnection(connectionString);

            using (myDbConnection)
            {
                cryptography encrypt          = new cryptography();
                string       crypFName        = encrypt.encryptString(fName);
                string       cryptLName       = encrypt.encryptString(lName);
                string       cryptAccessLevel = encrypt.encryptString(permissionsLevel);
                string       cryptUserId      = encrypt.encryptString(id);
                string       cryptVidLoc      = encrypt.encryptString(vidLoc);
                byte[]       cryptImage       = encrypt.encryptImage(imageBmp);
                byte[]       cryptTemplate    = encrypt.encryptTemplate(template);

                OleDbCommand command = new OleDbCommand();
                command.CommandType = CommandType.Text;
                command.Connection  = myDbConnection;
                command.CommandText = "INSERT INTO myTable (firstName, lastName, userId, permission, picture, template, videoLink) Values (@p1,@p2,@p3,@p4,@p5,@p6, @p7)";
                command.Parameters.AddWithValue("@P1", crypFName);
                command.Parameters.AddWithValue("@p2", cryptLName);
                command.Parameters.AddWithValue("@p3", cryptUserId);
                command.Parameters.AddWithValue("@p4", cryptAccessLevel);
                command.Parameters.AddWithValue("@p5", cryptImage);
                command.Parameters.AddWithValue("@p6", cryptTemplate);
                command.Parameters.AddWithValue("p7", cryptVidLoc);
                try
                {
                    myDbConnection.Open();
                    command.ExecuteNonQuery();
                }
                catch (OleDbException ex)
                {
                    DisplayOleDbErrorCollection(ex);
                    MessageBox.Show("No records were recorded");
                }
                finally
                {
                    myDbConnection.Close();
                }
            }
        }