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 7072247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:47:07+00:00 2026-05-28T05:47:07+00:00

Somehow, I couldn’t find out how to properly pass the data when a new

  • 0

Somehow, I couldn’t find out how to properly pass the data when a new record gets inserted, am sending the first column value back to WCF. Everything works, but I couldn’t pass the data. What am I missing?

CLR Trigger to call WCF:

public partial class Triggers
{

    public static EndpointAddress endpoint =  new EndpointAddress(new Uri("http://localhost:8000/services/myservice"));
    public static WSHttpBinding httpBinding = new WSHttpBinding();
    public static ServiceClient.ServiceReference1.ServiceContractClient myclient = new ServiceClient.ServiceReference1.ServiceContractClient(httpBinding, endpoint);
    public delegate void MyDelagate(String crudType);
    [SqlProcedure()]
    public static void SendData(String crudType)
    {
        myclient.UpdateOccured();//i was trying to pass the crudType value here 

    }

    [Microsoft.SqlServer.Server.SqlTrigger(Name = "WCFTrigger", Target = "tbCR", Event = "FOR INSERT")]
    public static void Trigger1()
    {

        SqlCommand cmd;
        SqlTriggerContext myContext = SqlContext.TriggerContext;
        SqlPipe pipe = SqlContext.Pipe;
        SqlDataReader reader;

        if(myContext.TriggerAction== TriggerAction.Insert)
        {
            using (SqlConnection conn = new SqlConnection(@"context connection=true"))
            {
                conn.Open();
                cmd = new SqlCommand(@"SELECT * FROM tbCR", conn);
                reader = cmd.ExecuteReader();
                reader.Read();

                //get the insert value's here
                string Name;
                Name = (string)reader[1];
                reader.Dispose();


                switch (myContext.TriggerAction)
                {
                    case TriggerAction.Update:

                         SendData(Name);

                        break;

                    case TriggerAction.Insert:

                        SendData(Name);
                    break;
                }
            }
        }

    }
}

My Service Contract:

namespace SampleService
{
    class MyService : IServiceContract
    {
        public void UpdateOccured()
        {
            Console.WriteLine("Update Occured");
        }

        public void InsertOccured(string Name)
        {
            Console.WriteLine("Insert Occured",Name);
        }

    }
}

Interface:

namespace SampleService
{
    [ServiceContract]
    interface IServiceContract
    {
        [OperationContract]
        void UpdateOccured();
        [OperationContract]
        void InsertOccured(string Name);
    }
}
  • 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-28T05:47:08+00:00Added an answer on May 28, 2026 at 5:47 am

    You should be selecting from INSERTED insertead of the actual table i.e.

    cmd = new SqlCommand(@"SELECT * FROM INSERTED", conn);
    

    Also, you should explicitly name the columns that you need instead of using *.

    INSERTED and DELETED and SQL Server created, memory-resident tables tables.

    More details

    The deleted table stores copies of the affected rows during DELETE and
    UPDATE statements. During the execution of a DELETE or UPDATE
    statement, rows are deleted from the trigger table and transferred to
    the deleted table. The deleted table and the trigger table ordinarily
    have no rows in common.

    The inserted table stores copies of the affected rows during INSERT
    and UPDATE statements. During an insert or update transaction, new
    rows are added to both the inserted table and the trigger table. The
    rows in the inserted table are copies of the new rows in the trigger
    table.

    An update transaction is similar to a delete operation followed by an
    insert operation; the old rows are copied to the deleted table first,
    and then the new rows are copied to the trigger table and to the
    inserted table.

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

Sidebar

Related Questions

somehow couldn't find this with a google search, but I feel like it has
this is my first post on stackoverlow and I couldn't find a solution to
I've looked at the documentation but I couldn't find if there was a method
couldn't find a similar topic but this may boil down to not knowing how
I'm a haskell newbie and I couldn't find an answer to this question. Can
i would like to ask about some Notepad++ feature that i couldn't find in
This has probably been answered dozens of times, couldn't find the answer though... Anyway,
Tried Googling , but couldn't find anything. I have a few files and folders
Please go through the simple scenario below, I couldn't find a better way to
im just wondering as I couldn't find an answer on google (well, maybe Ive

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.