Question

I created a new query in the dataset designer. There are now 2 queries there. The original one and the new one.

I also added named parameters in the Where clause of the 2nd query.

This is the query in the new one:

SELECT ID, FatherName, MotherName, EmergencyContactName, 
       EmergencyContactRelationship, Address1, Address2, City, State, Zip, 
       PrimaryPhone, SecondaryPhone, Email
  FROM Parents
 WHERE (FatherName = @FatherName)

The .Fill method that was generated by the wizard looks like this:

Me.ParentsTableAdapter.Fill(Me.ParentsDataSet.Parents)

This is calling the original query from the dataset designer.

Can you show me what additional coding I need to include so I can load a value into the @FatherName parameter and use it in a .Fill method that works with the new query and not the original one?

In the dataset designer the query I would like to use is the 2nd one listed in there.

Was it helpful?

Solution

If you for eaxamle named the other query FyllByFatherName then just call it allmost like the other one. All querys you Add to the tableadapter will be generatetd by its name so you can call it by code, your query parameters will be parameters in the procedure that is generated. So If you have named the query FillByFatherName, then call it like this:

Dim ParentDS as new ParentsDataSet

using ParentTA as new ParentsDataSetTableAdapers.ParentTableAdapter  
    'Get connectionstring from config.
    ParentTA.connection.connectionstring=my.settings.ParentDatasetConnectionstring

    'Fill without filter
    'ParentTA.Fill(ParentDS.Parents)

    'Fill by Fathers Name
     ParentTA.FillByFatherName(ParentDS.Parents,"Steven")
end using
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top