Solved

ADO.NET flowchart questions part 3

Posted on 2014-09-21
6
128 Views
Last Modified: 2014-09-28
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
0
Comment
Question by:Mike Eghtebas
  • 4
  • 2
6 Comments
 
LVL 11

Expert Comment

by:LordWabbit
ID: 40336187
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

0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 40337220
Hi LordWabbit,

In this figure:DataProvider
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 40337246
... 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
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 11

Accepted Solution

by:
LordWabbit earned 500 total points
ID: 40338732
Applies more to B, but you could load a data set with the data table, I always just found it a bit awkward working with a dataset with one data table.  Never been a fan of DataReaders - while you are working with them the connection is blocked, also the performance increase is negligible.  I read through your document, refers to pages which are not present.  Have you heard of the entity framework?  http://msdn.microsoft.com/en-us/data/ef.aspx
No one really uses ADO.Net directly anymore unless they need to talk to SQL older than 2005. (Which I sadly have to do).
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 40339360
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
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 40339364
Here is the file:
ADO-NET-Sep22.docx
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error when loading the database 16 58
Export import database 4 44
VS.net 2010 11 26
Code works but it's slow 24 45
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now