Quick Q: For the lInsertCommand, can one use Stored Procs? RRS feed

  • Question

  • I can try, but if someone can give me a quick answer, thanks.


    Currently, I am using SQL queries and setting the parameters, but I would like to do some additional work, which my stored procedure can handle during the inserts applied to the server.  A way around this would be to use an insert trigger and to use some type of flag that can be trigged only in the sync operation, but then that isn't as elegant.





    • Moved by Max Wang_1983 Friday, April 22, 2011 7:42 PM forum consolidation (From:SyncFx - Microsoft Sync Framework Database Providers [ReadOnly])
    Wednesday, May 7, 2008 1:59 PM

All replies


    Hi John,

    I think it is possible and is also the way I want to go.

    The following is taken from the LOB example:


    Code Snippet

    //client to server insert

    SqlCommand insertCommand = new SqlCommand();

    insertCommand.CommandText = "spInsertOrderDetails";

    insertCommand.CommandType = CommandType.StoredProcedure;

    insertCommand.Parameters.Add("@OrderDetailId", SqlDbType.UniqueIdentifier);

    insertCommand.Parameters.Add("@OrderId", SqlDbType.UniqueIdentifier);

    insertCommand.Parameters.Add("@InventoryId", SqlDbType.Int);

    insertCommand.Parameters.Add("@Quantity", SqlDbType.Int);

    insertCommand.Parameters.Add("@" + SyncSession.SyncRowCount, SqlDbType.Int).Direction = ParameterDirection.Output;



    What works definitely is those predefined parameters like "sync_last_received_anchor" but also parameters like in the above example, if there are columns in the synced table, that are named like the parameters the values are populated automatically. The only thing I am still unsure is if I can also add custom parameters, and values.

    Perhaps this could help you a bit.


    Regards, Andreas

    Monday, May 19, 2008 6:27 AM