Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2005

Tip: Looking for answers? Try searching our database.

Problem in Context connection of  CLR Trigger

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
None - 02 Aug 2005 10:42 GMT
Hi,

 I'm using June CTP Visual Studio 2005.

 I have Created CLR Object. In my CLR Method i have opened a
connection like below

public partial class Triggers
{
//In my CLR Method i have Opened the connection like below

[Microsoft.SqlServer.Server.SqlTrigger(Name="ClrTrigger",
Target="Triplets",Event="FOR INSERT")]
public static void CLRTrigger()
{
 Triggers objTriggers = new Triggers();
 objTriggers.Connection(true);
 ...
 .....
 Test();
// Here i'm calling one more method Test();

  ....
  ....
 objTriggers.Connection(false);
}

In this test method i'm Executing the command.
Public void Test()
{
 ....
 SqlCommand cmd = new SqlCommand();
 string cmdText = "select dirname from Docs where id=45";
 cmd.CommandText = cmdText;
 cmd.Connection = con;
 try
 {
  sdr = cmd.ExecuteReader();
 }
 catch (Exception exp)
 {
  WriteLog("R E ::: "+exp.Message);
 }
......
}
//Connection open and Close method
public void Connection(bool status)
{
 if (status)
 {
  con = new SqlConnection("context connection = true");
  con.Open();
 }
 else
 {
 con.Close();
 }
}
}

I'm getting the error of Connection already in use. I have properly
opened the connection in begin of method and Closed in end of method.
Inside the execution of method if i called some method means then it
can also use the same connection. Then Why its giving this error.
Please anybody knows solution to my problem let me know to solve it.

Thanks,
Vinoth

vinoth@gsdindia.com
Willy Denoyette [MVP] - 02 Aug 2005 11:22 GMT
Please post whidbey Beta issues to the forums set-up especially for whidbey
Beta.
http://forums.microsoft.com

The right forum for SQL2005 is found here:

http://forums.microsoft.com/msdn/ShowForum.aspx?ForumID=86

Willy.

> Hi,
>
[quoted text clipped - 66 lines]
>
> vinoth@gsdindia.com

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.