Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

doubt on Connections and Dataadapters

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stewart - 20 Jul 2007 13:10 GMT
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.
Siva M - 20 Jul 2007 13:26 GMT
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.

> Hi People,
>
[quoted text clipped - 14 lines]
>
> Thanks in advance.
Mark Rae [MVP] - 20 Jul 2007 13:58 GMT
> 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...

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.