1

I have encrypted every item in MS Access file using AES. Encryption works great. The problem is that I am getting an error: Argument 1: cannot convert from 'object' to 'string' On lines like these: security.Decrypt(readPersonalData.GetValue(1), storedAuth.Password, storedAuth.UserName)

How can I avoid this?

        if (readPersonalData.HasRows)
        {
            while (readPersonalData.Read())
            {
                // Count all entries read from the reader.
                countEntries++;


                txtDisplay.Text += "=== Entry ID: " + readPersonalData.GetValue(0) + " ===" + Environment.NewLine;
                txtDisplay.Text += "Type: " + security.Decrypt(readPersonalData.GetValue(1), storedAuth.Password, storedAuth.UserName) + Environment.NewLine;
                if (!readPersonalData.IsDBNull(2)) txtDisplay.Text += "URL: " + security.Decrypt(readPersonalData.GetValue(2), storedAuth.Password, storedAuth.UserName) + Environment.NewLine;
                if (!readPersonalData.IsDBNull(3)) txtDisplay.Text += "Software Name: " + security.Decrypt(readPersonalData.GetValue(3), storedAuth.Password, storedAuth.UserName) + Environment.NewLine;
                if (!readPersonalData.IsDBNull(4)) txtDisplay.Text += "Serial Code: " + security.Decrypt(readPersonalData.GetValue(4), storedAuth.Password, storedAuth.UserName) + Environment.NewLine;
                if (!readPersonalData.IsDBNull(5)) txtDisplay.Text += "User Name: " + security.Decrypt(readPersonalData.GetValue(5), storedAuth.Password, storedAuth.UserName) + Environment.NewLine;
                if (!readPersonalData.IsDBNull(6)) txtDisplay.Text += "Password: " + security.Decrypt(readPersonalData.GetValue(6), storedAuth.Password, storedAuth.UserName) + Environment.NewLine;
                txtDisplay.Text += Environment.NewLine;
            }
        }
2
  • 1
    What if you add a ToString() after your GetValue(1)? Commented Dec 1, 2011 at 8:18
  • Does not work. I have tried that. Commented Dec 1, 2011 at 8:28

1 Answer 1

2

You could try -

txtDisplay.Text += "Type: " + security.Decrypt(readPersonalData.GetString(1), storedAuth.Password, storedAuth.UserName) + Environment.NewLine;

Which should return a string that can be passed to the security.Decrypt function.

Sign up to request clarification or add additional context in comments.

1 Comment

@NewHelpNeeder, it is better that you upvote the answer besides accepting it, to express that it was useful.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.