Link to home
Start Free TrialLog in
Avatar of Mike Eghtebas
Mike EghtebasFlag for United States of America

asked on

ADO.NET flowchart questions part 3

Trying to make sense out of ADO.NET, I have summarized it in the attached 3-page doc file (under 300 words) with charts. Please add your valuable comments to it. I want to be corrected with wrong statements I may have made or my Figure 1 and 2 accurately depicting how ADO.NET works.

I am summarizing for my own understanding. There are a lots to read about it over the Web and books learn from; but I am finding them awfully confusing because there are very many similar terminologies and they jump back and forth with their descriptions.

Also, in page 3, please add some sample code you may want to share.

Thank you.
ADO-NET-EE1.docx
Avatar of LordWabbit
LordWabbit

This is probably the neatest way of using ado.net, although this method assumes that your SQL is clean and that the user has not used SQL injection.

    Private Function GetData(sql As String) As DataTable
        Dim con As SqlConnection = Nothing
        Dim command As SqlCommand = Nothing
        Dim adapter As SqlDataAdapter = Nothing
        Try
            con = New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("db").ConnectionString)
            con.Open()
            command = New SqlCommand(sql, con)
            adapter = New SqlDataAdapter(command)
            Dim table As New DataTable
            adapter.Fill(table)
            Return table
        Catch ex As Exception
            Return Nothing
        Finally
            If (IsNothing(con) = False) Then
                If (con.State = ConnectionState.Open) Then con.Close()
                con.Dispose()
            End If
            If (IsNothing(command) = False) Then
                command.Dispose()
            End If
            If (IsNothing(adapter) = False) Then
                adapter.Dispose()
            End If
        End Try
    End Function

Open in new window

Avatar of Mike Eghtebas

ASKER

Hi LordWabbit,

In this figure:User generated image
... In the above figure, does your solution applies to A or B?:
"The main function of Active Data Object (ADO) is to supply data to an application; it bridges the gap between the database and the application. It uses: A) DataAdapter with Dataset combination, B) DataAdapter w/o Dataset, C) DataReader, and D) TableAdapter which uses wizard plus some typed-code to handle the data flow."

I think it applies to option B because it is not building a dataset and data goes directly into a DataTable.

Please see the attached doc file for the entire text (less then 300 words).

Thanks,

Mike
ASKER CERTIFIED SOLUTION
Avatar of LordWabbit
LordWabbit

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

re:> No one really uses ADO.Net directly anymore...

I appreciate the info on this. The book I am studying will be discussing entity framework later. What I am learning though will serve me later to follow entity framework better.

I think, your code applies to option B only because your code is not discussing dataset (present with option A only).

The attached doc is the missing part (on oop). please read through and give me some feedback on it if you want it to.

about one data table: As you can see datatable collection implies that we can have more than one table in a dataset.

Question: Can we have more then on dataset? Where, a dataprovider creates/works with multiple dataset?

Thank you,

Mike
Here is the file:
ADO-NET-Sep22.docx