GRANT EXECUTE ON Table1 TO [Server01\Group1]; // Table name GRANT EXECUTE ON TestKey TO [Server01\Group1]; //stored procedure name
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;
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
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()
Gain unlimited access to on-demand training courses with an Experts Exchange subscription.Get Access
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE
Connect with Certified Experts to gain insight and support on specific technology challenges including: