Solved

ADO.NET flowchart questions part 3

Posted on 2014-09-21
6
127 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Log4Net custom Appender not being fired. 5 41
crm development 2 36
Check my code out(2) 1 27
VB.NET HttpWebRequest 12 30
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

13 Experts available now in Live!

Get 1:1 Help Now