Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 41191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:08:30+00:00 2026-05-10T15:08:30+00:00

I need to write a web application using SQL Server 2005, asp.net, and ado.net.

  • 0

I need to write a web application using SQL Server 2005, asp.net, and ado.net. Much of the user data stored in this application must be encrypted (read HIPAA).

In the past for projects that required encryption, I encrypted/decrypted in the application code. However, this was generally for encrypting passwords or credit card information, so only a handful of columns in a couple tables. For this application, far more columns in several tables need to be encrypted, so I suspect pushing the encryption responsibilities into the data layer will be better performing, especially given SQL Server 2005’s native support for several encryption types. (I could be convinced otherwise if anyone has real, empirical evidence.)

I’ve consulted BOL, and I’m fairly adept at using google. So I don’t want links to online articles or MSDN documentation (its likely I’ve already read it).

One approach I’ve wrapped my head around so far is to use a symmetric key which is opened using a certificate.

So the one time setup steps are (performed by a DBA in theory):

  1. Create a Master Key
  2. Backup the Master Key to a file, burn to CD and store off site.
  3. Open the Master Key and create a certificate.
  4. Backup the certificate to a file, burn to CD and store off site.
  5. Create the Symmetric key with encryption algorithm of choice using the certificate.

Then anytime a stored procedure (or a human user via Management Studio) needs to access encrypted data you have to first open the symmetric key, execute any tsql statements or batches, and then close the symmetric key.

Then as far as the asp.net application is concerned, and in my case the application code’s data access layer, the data encryption is entirely transparent.

So my questions are:

  1. Do I want to open, execute tsql statements/batches, and then close the symmetric key all within the sproc? The danger I see is, what if something goes wrong with the tsql execution, and code sproc execution never reaches the statement that closes the key. I assume this means the key will remain open until sql kills the SPID that sproc executed on.

  2. Should I instead consider making three database calls for any given procedure I need to execute (only when encryption is necessary)? One database call to open the key, a second call to execute the sproc, and a third call to close the key. (Each call wrapped in its own try catch loop in order to maximize the odds that an open key ultimately is closed.)

  3. Any considerations should I need to use client side transactions (meaning my code is the client, and initiates a transaction, executes several sprocs, and then commits the transaction assuming success)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T15:08:30+00:00Added an answer on May 10, 2026 at 3:08 pm

    1) Look into using TRY..CATCH in SQL 2005. Unfortunately there is no FINALLY, so you’ll have to handle both the success and error cases individually.

    2) Not necessary if (1) handles the cleanup.

    3) There isn’t really a difference between client and server transactions with SQL Server. Connection.BeginTransaction() more or less executes ‘BEGIN TRANSACTION’ on the server (and System.Transactions/TransactionScope does the same, until it’s promoted to a distributed transaction). As for concerns with open/closing the key multiple times inside a transaction, I don’t know of any issues to be aware of.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 181k
  • Answers 181k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think storing directly in DB would be the fastest… May 12, 2026 at 4:13 pm
  • Editorial Team
    Editorial Team added an answer Are your controls, textboxes, comboboxes, etc, bounded to a recordset?… May 12, 2026 at 4:13 pm
  • Editorial Team
    Editorial Team added an answer The following code works properly. Perhaps you are switching your… May 12, 2026 at 4:13 pm

Related Questions

I need a real DBA's opinion. Postgres 8.3 takes 200 ms to execute this
I need to force the initiation of download of a .sql file, when user
I have a web application (asp.net) where work items are submitted and allocated to
We are porting an old application that used a hierarchical database to a relational

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.