Hi. Im doing a login form with decryption. So i did a modification to my login code for decryption. Before i did the decryption, the login form is functioning well. But after i edit it to insert decryption code it suddenly cannot connect to database. Im still a begginer in vb.net so maybe there is something that Im missing because there is no error in the code so I dont know where did I do wrong.

Here i put decryption code(just in case) and my login code
Decryption Code

 Private Function Decrypt(ByVal cipherText As String) As String
        'Firstly the encrypted text i.e. cipher text is converted into bytes and then similar to the encryption process here too we will generate Key and IV using the derived bytes and the symmetric key.
        'Using MemoryStream and CryptoStream the cipher text is decrypted and written to byte array and finally the byte array is converted to Base64String and returned, which is the decrypted original text.
        Dim EncryptionKey As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789"
        Dim cipherBytes As Byte() = Convert.FromBase64String(cipherText)
        Using encryptor As Aes = Aes.Create()
            Dim pdb As New Rfc2898DeriveBytes(EncryptionKey, New Byte() {&H49, &H76, &H61, &H6E, &H20, &H4D, _
             &H65, &H64, &H76, &H65, &H64, &H65, _
             &H76})
            encryptor.Key = pdb.GetBytes(32)
            encryptor.IV = pdb.GetBytes(16)
            Using ms As New MemoryStream()
                Using cs As New CryptoStream(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write)
                    cs.Write(cipherBytes, 0, cipherBytes.Length)
                    cs.Close()
                End Using
                cipherText = Encoding.Unicode.GetString(ms.ToArray())
            End Using
        End Using
        Return cipherText

Login Code**

 Private Sub SubmitButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SubmitButton4.Click
        'Check ...

I got this problem while trying to disable or enable ports. It works well when Im using my friend's laptop but when I tried using my laptop, it give this error. Why was this happen and how to solve it? Thanks ^^

Private Sub DisableBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisableBtn.Click
        Microsoft.Win32.Registry.SetValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR", "Start", 4, Microsoft.Win32.RegistryValueKind.DWord) 'this line gives error
        MessageBox.Show("Port are disable", "USB Disable", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Me.Hide()
        Login.Show()
    End Sub

    Private Sub EnableBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EnableBtn.Click
        Microsoft.Win32.Registry.SetValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR", "Start", 3, Microsoft.Win32.RegistryValueKind.DWord) 'this line gives error
        MessageBox.Show("Port are enable", "USB Enable", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Me.Hide()
        Login.Show()
    End Sub

Im currently doing an application which is when user plugged in usb drive, login form will pop up so user need to login first but if user failed login for three times, webcam will automatically capture. The problem here, how to make the webcam to automatically capture after user failed to login after three times? I already found code for webcam from google but I dont know how to connect these to code to solve my problem.

This is the code for login without errors (in case u wanna see my code)

Imports System.Data.OleDb
    Public Class Login
        Private Sub LoginButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoginButton.Click
            'Check if username or password is empty
            If PasswordTextBox.Text = "" Or UsernameTextBox.Text = "" Then
                MessageBox.Show("Please fill-up all fields!", "Authentication Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
                'Clear all fields
                PasswordTextBox.Text = ""
                UsernameTextBox.Text = ""
                'Focus on Username field
                UsernameTextBox.Focus()
            Else
                ' Connect to DB
                Dim conn As New System.Data.OleDb.OleDbConnection()
                conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\PutLock.mdb"
                Try
                    'Open Database Connection
                    conn.Open()
                   Dim sql As String = "SELECT * FROM PutLockSignUp WHERE Username='" & UsernameTextBox.Text & "' AND Password = '" & PasswordTextBox.Text & "'"
                    Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)
                    Dim sqlRead As OleDbDataReader = cmd.ExecuteReader()
                    If sqlRead.Read() Then
                        MainPage.Show()
                        Me.Hide()
                    Else
                        ' If user enter wrong username or password
                        MessageBox.Show("Sorry, username or password not found!", "Authentication Failure", MessageBoxButtons.OK, MessageBoxIcon.Error)
                        'Clear all fields
                        PasswordTextBox.Text = ""
                        UsernameTextBox.Text = ""

                        'Focus on Username field
                        UsernameTextBox.Focus()
                    End If

                Catch ex As Exception
                    MessageBox.Show("Failed to connect ...