Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7065065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:54:39+00:00 2026-05-28T04:54:39+00:00

This thread is the continuation of the below thread Trigger Windows Service when the

  • 0

This thread is the continuation of the below thread
Trigger Windows Service when the new record insert in to DB

I got the code from Demo.B suggested

public partial class Triggers
{
    // Enter existing table or view for the target and uncomment the attribute line
    [Microsoft.SqlServer.Server.SqlTrigger(Name = "Trigger_Web", Target = "StoryItems", Event = "FOR INSERT")]
    public static void Trigger_Web()
    {
        SqlCommand command;
        SqlTriggerContext triggerContext = SqlContext.TriggerContext;
        SqlPipe pipe = SqlContext.Pipe;
        SqlDataReader reader;

        if (triggerContext.TriggerAction == TriggerAction.Insert)
        {
            using (SqlConnection connection = new SqlConnection(@"context connection=true"))
            {
                connection.Open();
                command = new SqlCommand(@"SELECT * FROM StoryItems", connection);
                reader = command.ExecuteReader();
                reader.Read();

                // get inserted value
                string Name;
                string Location;
                Name = (string)reader[1];
                Location =(string)reader[2];
                reader.Close();
                //try
                //{
                //    // try to pass parameter to windows service

                //    //WindowsService param = new WindowService(Name, Location);
                //    //Do something if it pass

                //}
                //catch (Exception ex)
                //{

                //}

                // Replace with your own code
                SqlContext.Pipe.Send("Trigger FIRED");
            }
        }
    }
}

I am facing few problem when i start execute,first of all it ask me change the version from 4.0 to lower (so changed the version to 3.5 in the properties).

When i try to step into its not working and all the time it says deploy succeed and the output window shows “Canceled by User”. Am not sure what going on the behind scene.

Please some one advise me how can i execute and see some results when the new row is inserted.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:54:40+00:00Added an answer on May 28, 2026 at 4:54 am

    No, it does not. SQLCLR support for .Net 4.0 comes only in SQL Server 2012. However your Visual Studio knows better and will compile and deploy your DLLs as a .Net 2.0 assembly.

    Other than that, doing Web calls from a trigger is a very bad idea. Your database will grind to a halt waiting on responses from WWW. Use a queueing mechanism and make the WWW call from process of your own, not from SQLCLR.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Take this thread: Thread thread = new Thread(delegate() { //Code }); thread.Start(); Should it
This is a continuation of this thread: Div Borders Affecting Padding . I've got
This question is in continuation to my existing thread . Below given is a
This is partly a continuation from this thread: jquery - return value from callback
In this thread some one commented that the following code should only be used
This question is based on this thread . The code function man() { man
This is inspired by/taken from this thread: http://www.allegro.cc/forums/thread/603383 The Problem Assume the user gives
This question is a continuation of this thread : In short: To solve my
This question is a continuation of a previous thread to compare two lists with
This thread got too confusing (for me) so I am asking the question again.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.