Click here to Skip to main content
14,692,015 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

Hopefully a quick question.

I have a SQL Server 2010 (standard) database and am experimenting with column encryption.

All going well, excpet that I don't appear to be able to retrieve the data back out of the table using a stored procedure from an ASP.Net web site.

The stored procedure is called and the SELECT statement is issued and a DataTable is returned. On attempting to retrieve the data from the column, the ASP.Net code thinks that the data is NULL.

I can get the INSERTS and SELECTS working fine in SQL Server studio to show me the data.

The SELECT part (excerpt) of the statement looks like this

...
CAST(DecryptByKey(FirstName) AS varchar(50)) As FirstName
...

and on returning to the code I can see (whilst debugging) that the column exists in the DataTable but with no data in it.

Can anyone help, I'm running out of ideas and, as ever, timescales are short.... :)

Many thanks

Julian
Posted
Updated 21-Jul-20 11:54am

Don't worry, sorted it.

I had my OPEN SYMMTERIC KEY statement in the Stored Procedure in the wrong place.

It looked like this:

OPEN SYMMETRIC KEY SymKey1_TOOS
DECRYPTION BY CERTIFICATE CERT1_TOOS;

ALTER PROCEDURE [dbo].[Test004]
(
@CustomerID int
)
AS

SELECT
CustomerID,
etc...

instead of:

ALTER PROCEDURE [dbo].[Test004]
(
@CustomerID int
)
AS
BEGIN
OPEN SYMMETRIC KEY SymKey1_TOOS
DECRYPTION BY CERTIFICATE CERT1_TOOS;

SELECT
CustomerID,
etc...

Hooray...

J
   
Hi julian,

Plese follow the following link which may help you to find out the solution.

http://www.kodyaz.com/articles/sql-server-2005-database-encryption-step-by-step.aspx
   
Yeah, but now your sending sensitive data in clear text over the wire....
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900