doubt on Connections and Dataadapters

Discussion in 'ASP .Net' started by Stewart, Jul 20, 2007.

  1. Stewart

    Stewart Guest

    Hi People,

    I have been coding in vb.net and c# for last six months, I am new to
    coding and we are using 3 tier architecture. In the DAL in each and
    every method I open the connection and close it in the finally block
    of the try catch block, if I am not using a DataAdapter.
    1. Is this correct?
    2. should I be using only the dataadapter always, like for insertion
    of single record, updation of single record, etc. The general practice
    is to use the Dataadapter to only when a DataTable or Dataset comes
    into picture.
    3. Will there be any performance issues?

    This question I have may be silly, but I need this. I want to have the
    right code.
    :)

    Thanks in advance.
     
    Stewart, Jul 20, 2007
    #1
    1. Advertising

  2. Data adapter is a sort of bridge between dataset/datatable and the actual
    data source (such as SQL Server, Oracle, etc). So, you need a data adapter
    instance when you want to fetch data from your DB or persist data changes
    from dataset/datatable to the DB. There is no need to create a data adapter
    otherwise.

    "Stewart" wrote:

    > Hi People,
    >
    > I have been coding in vb.net and c# for last six months, I am new to
    > coding and we are using 3 tier architecture. In the DAL in each and
    > every method I open the connection and close it in the finally block
    > of the try catch block, if I am not using a DataAdapter.
    > 1. Is this correct?
    > 2. should I be using only the dataadapter always, like for insertion
    > of single record, updation of single record, etc. The general practice
    > is to use the Dataadapter to only when a DataTable or Dataset comes
    > into picture.
    > 3. Will there be any performance issues?
    >
    > This question I have may be silly, but I need this. I want to have the
    > right code.
    > :)
    >
    > Thanks in advance.
    >
    >
     
    =?Utf-8?B?U2l2YSBN?=, Jul 20, 2007
    #2
    1. Advertising

  3. "Stewart" <> wrote in message
    news:...

    > I have been coding in vb.net and c# for last six months, I am new to
    > coding and we are using 3 tier architecture.


    That's good.

    > In the DAL in each and every method I open the connection and close
    > it in the finally block of the try catch block, if I am not using a
    > DataAdapter.
    > 1. Is this correct?


    Yes, though an even easier method is to use the "using" syntax e.g.

    using (SqlConnection SqlConn = new SqlConnection(SqlConnStr))
    {
    using (SqlCommand SqlComm = new SqlCommand(strSQL, SqlConn))
    {

    }
    }

    > 2. should I be using only the dataadapter always, like for insertion
    > of single record, updation of single record, etc.


    No - you should be using the command object's ExecuteNonQuery method for
    that...

    > The general practice is to use the Dataadapter to only when a DataTable
    > or Dataset comes into picture.


    Correct.

    > 3. Will there be any performance issues?


    No - quite the reverse...


    --
    Mark Rae
    ASP.NET MVP
    http://www.markrae.net
     
    Mark Rae [MVP], Jul 20, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vik

    Loop through all dataadapters

    Vik, Jul 16, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    363
  2. Jon Maz
    Replies:
    4
    Views:
    418
    Jon Maz
    May 27, 2004
  3. =?Utf-8?B?Sko=?=

    Sql DataAdapters

    =?Utf-8?B?Sko=?=, Jul 5, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    519
    =?Utf-8?B?Sko=?=
    Jul 5, 2005
  4. Tina
    Replies:
    0
    Views:
    366
  5. Replies:
    0
    Views:
    433
Loading...

Share This Page