Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8894461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:30:10+00:00 2026-06-14T23:30:10+00:00

Good-day, I need help with iterating through a DataTable (dbTable) and decrypting a particular

  • 0

Good-day,

I need help with iterating through a DataTable (dbTable) and decrypting a particular field (ccNumber) before assigning its items to a Listview control (ListViewRecords).

I’ve already used the decryption code below elsewhere in my project on a Textbox with success, but can’t figure out how to do it with the DataTable. Your assistance would be greatly appreciated, thanks.

HERE’S THE DECRYPTION CODE:

    Dim DES As New System.Security.Cryptography.TripleDESCryptoServiceProvider
    Dim Hash As New System.Security.Cryptography.MD5CryptoServiceProvider
    Try
        DES.Key = Hash.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(My.Settings.Key))
        DES.Mode = System.Security.Cryptography.CipherMode.ECB
        Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateDecryptor
        Dim Buffer As Byte() = Convert.FromBase64String(TextBoxCard.Text)
        TextBoxCard.Text = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
    Catch ex As Exception
        MessageBox.Show("The following error(s) have occurred: " & ex.Message, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Try

HERE’S THE CODE TO QUERY THE DB AND FILL THE LISTVIEW:

Private Sub loadRecords()
    'FOR MySQL DATABASE USE
    Dim dbConn As New MySqlConnection
    Dim dbTable As New DataTable
    Dim dbQuery As String = ""
    Dim dbCmd As New MySqlCommand
    Dim dbAdapter As New MySqlDataAdapter
    dbTable.Clear()

    Try

        If dbConn.State = ConnectionState.Closed Then
            dbConn.ConnectionString = String.Format("Server={0};Port={1};Uid={2};Password={3};Database=accounting", FormLogin.ComboBoxServerIP.SelectedItem, My.Settings.DB_Port, My.Settings.DB_UserID, My.Settings.DB_Password)
            dbConn.Open()
        End If

        dbQuery = "SELECT *" & _
                   "FROM cc_master INNER JOIN customer ON customer.accountNumber = cc_master.customer_accountNumber " & _
                   "ORDER BY nameCOMPANY ASC"
        With dbCmd
            .CommandText = dbQuery
            .Connection = dbConn
        End With
        With dbAdapter
            .SelectCommand = dbCmd
            .Fill(dbTable)
        End With
        ListViewRecords.Items.Clear()
        For i = 0 To dbTable.Rows.Count - 1
            With ListViewRecords
                .Items.Add(dbTable.Rows(i)("ccID"))
                With .Items(.Items.Count - 1).SubItems
                    .Add(dbTable.Rows(i)("nameCOMPANY"))
                    .Add(dbTable.Rows(i)("ccNumber"))
                    .Add(dbTable.Rows(i)("ccExpireMonth"))
                    .Add(dbTable.Rows(i)("ccExpireYear"))
                    .Add(dbTable.Rows(i)("ccType"))
                    .Add(dbTable.Rows(i)("ccAuthorizedUseStart"))
                    .Add(dbTable.Rows(i)("ccAuthorizedUseEnd"))
                    .Add(dbTable.Rows(i)("ccLocation"))
                    .Add(dbTable.Rows(i)("cardholderSalutation"))
                    .Add(dbTable.Rows(i)("cardholderLastname"))
                    .Add(dbTable.Rows(i)("cardholderFirstname"))
                    .Add(dbTable.Rows(i)("ccZipcode"))
                End With
            End With
        Next
    Catch ex As MySqlException
        MessageBox.Show("A DATABASE ERROR HAS OCCURED" & vbCrLf & vbCrLf & ex.Message & vbCrLf & _
                    vbCrLf + "Please report this to the IT/Systems Helpdesk at Ext 131.")
    End Try
    dbConn.Close()

End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:30:11+00:00Added an answer on June 14, 2026 at 11:30 pm

    Put the decryption thing in a function:

    Function Decrypt(ByVal ToDecrypt) as String
    Dim DES As New System.Security.Cryptography.TripleDESCryptoServiceProvider
            Dim Hash As New System.Security.Cryptography.MD5CryptoServiceProvider
            Try
                DES.Key = Hash.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(My.Settings.Key))
                DES.Mode = System.Security.Cryptography.CipherMode.ECB
                Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = DES.CreateDecryptor
                Dim Buffer As Byte() = Convert.FromBase64String(ToDecrypt)
                return  System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
            Catch ex As Exception
                return "Whatever failed message you want"
            End Try
    End Function
    

    Then loop through your table like this and change the value:

    for i as Integer = 0 to dbTable.Rows.Count - 1
    dbTable.Rows(i)("ccNumber")) = Decrypt(dbTable.Rows(i)("ccNumber"))
    

    This should work if I’m not totally off.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good day. I need some help. I want to make program in Delphi, and
Good day, I need some help with MS Access and a query. My SQL
Good day. I need to teach Windows CryptoAPI to encrypt the message with private
Good day, I have like 15 images I need to be buttons. I have
Good day, I have a requirement which i need to include a layout (actually
Good day everyone I need to execute command on linux machine this command is
Good day, I need to extract portion of string which can looks like this:
Good day to everyone! I need to stop method execution until another activity will
Good day. I need to format a number in java. So far I have
Good day. I could really use your help on this one. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.