ADO.NET Code showing Dataset storing multiple tables

ADO.NET Code showing Dataset storing multiple tables

- Declare and initialize database connection object with appropriate connection string.
- Create a DataAdapter and a Dataset object.
- Using fill method of the DataAdapter object, load the data into the Dataset Object.
- Change the adapter's SELECT command.
- Create the EmpDetail table.
- Add both tables to a single dataset.
- Display the data using data binding feature of controls like Datagrid or Datalist.
Dim m_adptEmp As SqlDataAdapter

Private Sub Page_Load(ByVal sender As System.Object, _ByValeAsSystem.EventArgs)HandlesMyBase.Load<BR> DimEmpConnAsNewSqlConnection_<BR> ("server=(local);database=Employees;Trusted_Connection=yes")
     m_adptEmp = New SqlDataAdapter("select * from Emp", EmpConn)
     Dim dsEmp As New DataSet
     m_adptEmp.Fill(dsEmp, "Emp")
     adptEmp.SelectCommand.CommandText = "SELECT * FROM EmpDetail"
     Dim EmpDetail As New DataTable("EmpDetail")
     adptDB.Fill(EmpDetail)
     dsBoth.Tables.Add(Emp)
     dsBoth.Tables.Add(EmpDetail)
     DataGrid1.DataSource = dsEmp.Tables("Emp").DefaultView
     DataGrid1.DataBind()
End Sub
ADO.NET Code executing stored procedure
ADO.NET Code executing stored procedure - Code showing how to fetch data using Stored Procedure...
ADO.NET transaction Processing
ADO.NET transaction Processing - The transaction object handles concurrency issue using IsolationLevel settings. The settings can be....
Explain the namespaces in which .NET has the data functionality class.
System.data contains basic objects. These objects are used for accessing and storing relational data....
Post your comment