Trigger Context Connection is Already in use by Other Session.

Hi,

I have Created CLR Trigger(SQL Server Project) Project.

In that project i have used the Following Code.
SqlConnectioncon =newSqlConnection("context connection = true");
con.Open();

// Some Proceesing based on the row Inserted.

con.Close();

After Closing the Connection I want to open a New SqlConnection for other Database like below.

string conStr = "Server=192.168.1.25;Database=" + DatabaseName + ";User Id=" + UserId + ";Password=" + Password;

SqlConnection con =newSqlConnection(conStr);
con.Open();


When i try to do this its giveing the following error:

Error:-
Trigger Context Connection is Already in use by Other Session.

Is it not possible to open a new conncetion for Other database from the CLR Trigger Project?
If anybody knows the solution let me know to solve it.

Thanks
Vinoth

[1299 byte] By [Vinoth] at [2008-2-18]
# 1

Is the error actually "Trigger context is already in use by other session" (no "connection")? And is the database you are connecting to on the same server (i.e. loopback connection)? If so, and if you don't need the loopback connection to use the same transaction as the DML that fired the trigger, you can add "enlist = false" to your connection string and it should correct the trouble.

--
~Alazel

Alazel Acheson
Software Developer
Microsoft SQL Server
This posting is provided "AS IS" with no warranties, and confers no rights.
AlazelAcheson at 2007-9-9 > top of Msdn Tech,SQL Server,.NET Framework inside SQL Server...

SQL Server

Site Classified