views:

257

answers:

1

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.

+4  A: 

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

  using(SqlConnection connection = new SqlConnection("context connection=true")) 
  {
      // ..
  }
Jakob Christensen
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.
Pasi Savolainen