When use table adapter pattern in a data set to connect to database most of the time there is no coding necessary.
use a asp:ObjectDataSource control to rfer to the table adapter object and then use that data source in the control
similar to following
aspx page
<ItemTemplate>
<asp:DropDownList ID=”DropDownList1″ runat=”server”
DataSourceID=”ObjectLUShift” DataTextField=”Shift” DataValueField=”ShiftNumber”
SelectedValue=’<%# Eval(“ShiftNumber”) %>’ >
</asp:DropDownList>
<asp:ObjectDataSource ID=”ObjectLUShift” runat=”server”
OldValuesParameterFormatString=”original_{0}” SelectMethod=”GetShift”
TypeName=”LogTableAdapters.LUShiftTableAdapter”></asp:ObjectDataSource>
</ItemTemplate>
But if programmatically needs to access the table adapters sample code would be bit similar to following
All the connection info and query is with data access layer (data set and table adapters in it.)
aspx.cs page
FutureTrainingCoursesTableAdapter FutureTrainingCoursesAdapter = new FutureTrainingCoursesTableAdapter();
Training.FutureTrainingCoursesDataTable FutureTrainingCoursesTable = new Training.FutureTrainingCoursesDataTable();
FutureTrainingCoursesTable = FutureTrainingCoursesAdapter.GetCurrentTraining2();
foreach (Training.FutureTrainingCoursesRow Row in FutureTrainingCoursesTable)
{
Id = Convert.ToString(Row.ID);