2

I am creating a C# assembly for MS SQL Server 2005 for encryption/decryption.

I need to query the database in this assembly, and was wondering what the preferred method of connecting to the database is? I believe we would not want to have a username/password in the connection string.

Since the assembly is registered in MS SQL does it have some sort of quick way to access data in the database?

I'm a little bit of a newb as it related to Integrated Security or Trusted Connections.

1 Answer 1

5

You can use the following connection string when using CLR stored procedures:

 using(SqlConnection connection = new SqlConnection("context connection=true")) { // .. } 
Sign up to request clarification or add additional context in comments.

1 Comment

The "using" part is very, very important. We had "connection already opened" errors pop up fairly randomly and I swear all paths closed the connections/streams/queries, but when I replaced all the explicit .Close():s with using's, it just went away.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.