locked
syntax for entering multiple parameters for a tableadapter.fill command RRS feed

  • Question

  • What is the syntax to include more than 1 parameter in the command line for a tableadapter.fill command

     

    example command:   

    Me.V_DoctorGrid1TableAdapter.Fill(Me.MDXDataSet.v_DoctorGrid1, gstrGroupID)

     

    gstrGroupID is one parameter.  I need to add an additional parameter.

     

    Thanks...

     

    Monday, March 24, 2008 7:37 PM

Answers

  • You need to edit the command text of the Fill query.  As you add parameters to the query string they will become available to use with the table adapter.

     

    For instance, right now you might have something like this:

     

    SELECT * FROM DoctorGrid1 WHERE gstrGroupID = @gstrGroupID

     

    You need to update that to something like this:

     

    SELECT * FROM DoctorGrid1 WHERE gstrGroupID = @gstrGroupID AND Name = @Name

     

    This will give you a second parameter when using the Fill function

     

    Me.V_DoctorGrid1TableAdapter.Fill(Me.MDXDataSet.v_DoctorGrid1, gsrGroupID,Name)

     

    That should answer your question but as an added note, I don't usually recomend this.  Generally I try to leave the Fill query that is automatically generated when you create the table adapter alone.  Each time I need to make a more specific query I just write a new one.  The reason is that you might need the more general queries at a later date, and your just going to have to write them then anyway.  Another thing that I do is Make the name specific to the function.  So In your case I would have three queries

     

    Fill - Fills Table with no filtering

    FillByGroupID - Fills Table with only records in a particular Group

    FillByGroupIDName - Fill Table with only records in a particular Group with a particular name

     

    Hope this helps.

    Monday, March 24, 2008 8:16 PM