Error VB.net

Hi
Following code is working FINE at my computer. im login as Db_Owner

When im runing at some collegue machine, Following error
Error
The key is not encrypted using the specified decryptor

I gave grant to run, I created Group called Group1 and add the users and give the
access as Public DB_Datareader and DB_DataReader
and also gave Following
GRANT EXECUTE ON Table1 TO [Server01\Group1]; // Table name
GRANT EXECUTE ON TestKey TO [Server01\Group1]; //stored procedure name

Open in new window

========================================================
Create Key code vB.net
 string TempKey = txtKeyNumber.Text.ToString();
                string strCreateSymmeticKey;
                strCreateSymmeticKey="CREATE SYMMETRIC KEY TestSymmetricKey";
                strCreateSymmeticKey=strCreateSymmeticKey+" "+"WITH ALGORITHM = AES_256";
                strCreateSymmeticKey = strCreateSymmeticKey + " " + "ENCRYPTION BY PASSWORD = '" + TempKey + "'";



                cmd.CommandText = strCreateSymmeticKey;

Open in new window

========================================================
Sored Procedure
========================================================
Create Procedure TestKey
@Empnumber varchar(7),
@KeyNumber nvarchar(100)
as


DECLARE @open nvarchar(4000)
SET @open = 'OPEN SYMMETRIC KEY TestSymmetricKey  DECRYPTION BY PASSWORD =' + quotename (@KeyNumber,'''')
EXEC sp_executesql @open

SELECT CONVERT(NVARCHAR(4000),DecryptByKey(salary)) FROM (SELECT *,ROW_NUMBER() OVER(PARTITION BY emp_num ORDER BY RecordDate DESC)'RowNum'  FROM Table1  )sub
WHERE RowNum = 1 and emp_num=@Empnumber
CLOSE SYMMETRIC KEY TestSymmetricKey

Open in new window

========================================================
Calling Code
========================================================
VB.net code
connection 1= New SqlConnection(connetionString)
connection1.open()
co1.Connection =connection
co1.CommandText="TestKey"
co1.CommandType = CommandType.StoredProcedure
co1.parameters.Add("@KeyNumber", sqlDBType.varchar).value = KeyValue1
reader=co1ExecuteReader()

Open in new window

Error
The key is not encrypted using the specified decryptor


Could some one show me where is the mistake or any advice highly appriciate.
Thanks
LVL 10
ukerandiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vitor MontalvãoMSSQL Senior EngineerCommented:
Where do you run the 'CREATE SYMMETRIC KEY' statement?

And also 'GRANT EXECUTE ON Table1 TO [Server01\Group1]' is wrong. You don't grant execution on tables but SELECT, INSERT, UPDATE and DELETE.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ste5anSenior DeveloperCommented:
Can you please rephrase your question and descibe, what you're trying to do?
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
Nice work aikimark.
0
Vitor MontalvãoMSSQL Senior EngineerCommented:
So, you really needed to run the 'CREATE SYMMETRIC KEY' statement, right?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Encryption

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.