none
how to force schema errors to be ignored on update command RRS feed

  • Question

  • I'm using the DataAdapter and CommandBuilder to generate the ins/upd/del/sel sprocs and parameters that I then use to update a table from various typed datasets.  the Table the sprocs are generated from is generic and I'm using custom mappings when I create the various dataadapters based on the typed dataset.

    there are ~15 static columns that have names and are common across all typed datasets but the remaining are generic (mostly sql_variant).  The typed dataset (TPerson for example will have things like 'LastName' but would map to the table value 'field11'.  the custom mappings I set when I create the TPerson specific adapter I think handles the translation.

    I use the following settings on the dataadapter in an attempt to ignore the differences between the typed dataset and the commands generated:

                    da.MissingMappingAction = MissingMappingAction.Ignore;
                    da.MissingSchemaAction = MissingSchemaAction.Ignore;
    

    This works fine on the insert command.

    However, on the update command, it is failing because it is looking for a mapping to @Original_field13 which I don't have in the typed dataset.  In the case of the typed dataset TPerson and the generic sproc updating the generic table, field13 is the first parameter that is not used so there is not mapping set up for it. 

    My hope was that the UpdateCommand would work like the InsertCommand and the differences would be ignored and the command would execute.

    However, I'm getting the following error:

    -  sqex {"The parameterized query '(@IsDeleted bit,@DeletedOn smalldatetime,@Original_ObjectId uniq' expects the parameter '@Original_field13', which was not supplied."} System.Data.SqlClient.SqlException

    Any ideas on how to get around this issue.  I'm working on a POC and this is blocking my current design and need to determine if I need to pick an alternate path.

    Any help will be greatly appreciated!!!

    Thanks

    Sunday, June 22, 2014 4:15 PM

Answers

  • Hello,

    As far as  know, the MissingSchemaAction is working when adding data as it describes:

    Specifies the action to take when adding data to the DataSet and the required DataTable or DataColumn is missing.

    So inserting is ok. However, there is not similar enumeration for update command. In my opinion, there should be limits for it although there is not exact document for this command.

    The MissingMappingAction is used to determine the action to take when incoming data does not have a matching table or column not for updating.

    I think you may need to create command for each dataset using CommandBulider although it needs more code.

    If I misunderstand, please let me know.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by bmobile Monday, June 30, 2014 2:01 PM
    Monday, June 23, 2014 2:58 AM
    Moderator

All replies

  • Hello,

    As far as  know, the MissingSchemaAction is working when adding data as it describes:

    Specifies the action to take when adding data to the DataSet and the required DataTable or DataColumn is missing.

    So inserting is ok. However, there is not similar enumeration for update command. In my opinion, there should be limits for it although there is not exact document for this command.

    The MissingMappingAction is used to determine the action to take when incoming data does not have a matching table or column not for updating.

    I think you may need to create command for each dataset using CommandBulider although it needs more code.

    If I misunderstand, please let me know.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by bmobile Monday, June 30, 2014 2:01 PM
    Monday, June 23, 2014 2:58 AM
    Moderator
  • Thanks for the response Fred.  I ended up generating specific sprocs for the one table that are related to the views that I've created.  I used the wizard that does this with the DataAdapter.

    Monday, June 30, 2014 2:01 PM