Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > doubt on Connections and Dataadapters

Reply
Thread Tools

doubt on Connections and Dataadapters

 
 
Stewart
Guest
Posts: n/a
 
      07-20-2007
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.

 
Reply With Quote
 
 
 
 
=?Utf-8?B?U2l2YSBN?=
Guest
Posts: n/a
 
      07-20-2007
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.
>
>

 
Reply With Quote
 
 
 
 
Mark Rae [MVP]
Guest
Posts: n/a
 
      07-20-2007
"Stewart" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...

> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
asp 2.0 DataAdapters always reset to null on page load drisso@ortc.com ASP .Net 0 03-17-2006 06:28 PM
where are my dataadapters in 2005? Tina ASP .Net 0 12-23-2005 06:54 PM
Sql DataAdapters =?Utf-8?B?Sko=?= ASP .Net 2 07-05-2005 03:48 PM
Optimising Connections & DataAdapters Jon Maz ASP .Net 4 05-27-2004 05:02 PM
Loop through all dataadapters Vik ASP .Net 2 07-17-2003 02:04 PM



Advertisments