none
SyncAdapter Command Parameters RRS feed

  • Question

  • I'm working on defining classes that'll inherit from SyncAdapter, but I'm having a bit of trouble understanding how records from a client table are matched up with the proper parameters in a command's Parameters collection.

     

    For example, if I have the table XYZ & it has the columns A, B, C. My InsertCommand would be

    INSERT INTO [XYZ] (A, B, C) VALUES (@A, @B, @C)

     

    and my parameters collection would be updated like below

     

    InsertCommand.Parameters.Add("@A", SqlDbType.Int);
    
    InsertCommand.Parameters.Add("@B", SqlDbType.Int);
    
    InsertCommand.Parameters.Add("@C", SqlDbType.Int);
    
    

     

    Now assume I've entered a record into the XYZ table on a client database. When synchronizing, how does the framework determine that the value in column A on a client should be mapped to the parameter @A if I haven't explicitly said so? Is it based upon column order in the databases? What happens if I exclude a column from synchronization (like column B)?

    Monday, March 21, 2011 7:47 PM

Answers

  • if i remember it right, Sync Fx internally loops thru each column and compares it with the parameter names and assigns the value accordingly.

    the values you assigned in your parameters above will get overwritten by the values assigned by Sync Fx when it loops thru the data rows to be applied and assign the parameter values.

    • Marked as answer by hoffmanpm2 Tuesday, March 22, 2011 5:13 PM
    Tuesday, March 22, 2011 3:39 PM
    Moderator

All replies

  • afaik, it's by column name
    Tuesday, March 22, 2011 12:45 AM
    Moderator
  • I guess I'm missing something. I suppose what I don't understand is how the column names are associated with the parameters. In other words, when I insert a record how does the framework know to supply value A from client table XYZ for the parameter @A. I do not explicitly associate the two unless the sync framework is somehow considering the syntax of the InsertCommand.

     

    I tried using InsertCommand.Parameters.Add("@B", SqlDBType.Int, 0, "C") & InsertCommand.Parameters.Add("@C", SqlDbType.Int, 0, "B") to switch the values held by these columns but they retained their values.

    Tuesday, March 22, 2011 1:16 PM
  • if i remember it right, Sync Fx internally loops thru each column and compares it with the parameter names and assigns the value accordingly.

    the values you assigned in your parameters above will get overwritten by the values assigned by Sync Fx when it loops thru the data rows to be applied and assign the parameter values.

    • Marked as answer by hoffmanpm2 Tuesday, March 22, 2011 5:13 PM
    Tuesday, March 22, 2011 3:39 PM
    Moderator