Showing posts with label clr. Show all posts
Showing posts with label clr. Show all posts

Monday, 19 March 2012

Connect same database in the CLR store procedure

Hi everybody:

I have a urgent problem, and can not google any useful answer. Please help me!

In my CLR store procedure, I have used a context connect, and I want to creat another connect to the same database. I have set the database permission to external, creat asymmetric key in my assembly, and creat login for that key. The dbo is the owner.

When I use this connect string as store procedure input, and I opened this new connect in the CLR sp, it throw an exception --"***.MDF is in used, failed to connect"!!

How can I do?

Thank you very much!

Why do you need to connect back to the same database from the CLR stored procedure?

Opening a connection back to the same database is not supported for CLR integration stored procedures. If you are trying to achieve a multiple active result set scenario on the server, your best bet is to use server side cursors. You may wish to check out the ResultSet sample which demonstrates how to use cursors from CLR integration code. This sample would normally be located at systemdrive:\Program Files\Microsoft SQL Server\90\Samples\Engine\Programmability\CLR\ResultSet\ after following the instructions for installing samples in the topic "Installing Samples" in SQL Server 2005 Books Online. For more information about this sample, see http://msdn2.microsoft.com/en-us/library/ms160831(SQL.90).aspx.