0

Hi there,

I have a question in EncryptByPassPhrase.
I am trying to encrypt the source column in the database table PForm. When I run the code it sasys, “Failed to convert parameter value from a String to a Byte[].”
the SourcePath column in the database is varBinary(256) type.
What is the problem over here.

public void AddFormDetails(string ID, string SourcePath)
        {
            string query = @"Insert into PForm(ID, SourcePath) 
                                    Values(@id,EncryptByPassPhrase('AdminApplication',@source)";
            SqlCommand command = new SqlCommand(query, DB.getConnection());

            command.Parameters.Add("@id", SqlDbType.VarChar).Value = ID;
            
            command.Parameters.Add("@source", SqlDbType.VarBinary).Value = SourcePath ;
            
            db.openConnection();
            command.ExecuteNonQuery();
            db.closeConnection();
        }
1
Contributor
2
Replies
3
Views
6 Years
Discussion Span
Last Post by judithSampathwa
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.