473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

doubt on Connections and Dataadapters

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.

Jul 20 '07 #1
2 1193
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.

Jul 20 '07 #2
"Stewart" <ma**********@gmail.comwrote in message
news:11*********************@z28g2000prd.googlegro 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

Jul 20 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mudge | last post by:
Hi, My hosting provider only allows me to use 50 connections to my MySQL database that my Web site will use. I don't know what this 50 connections means exactly. Does this mean that only 50...
0
by: hillscottc | last post by:
I have two DataAdapters....1)daStandard does a SELECT *, and 2)daDuplicates uses a stored proc which returns only rows with some duplicate data. Problem is, when I butRefresh_Click and I have...
2
by: Vik | last post by:
Is it possible to loop through all dataadapters on page? Thanks
4
by: Jon Maz | last post by:
Hi, I just read the following in an old NG thread: "when you use the adapter with a closed connection it will open it, do your requested database access, and close it immediately. If you use...
2
by: Dave Cullen | last post by:
Can someone please explain the relationship between data adapters, connections, and datasets? Why would an application have one adapter and multiple data connection objects? Does each form that...
2
by: JohnT | last post by:
Okay... I'm using VB.net (2003) and I am accessing an MS Access DB file. I have two DataAdapters that I use to search for specific info. The two of them are similar except one is a Date, the...
0
by: Tina | last post by:
I converted my project and it runs ok but when I look at that .aspx page there are no dataadapters. I have tried help and msdn search with words like "conversion" "upgrade" " 2003 to 2005" and...
0
by: drisso | last post by:
I found it convenient in asp.net 1.1 that you could easily define a dataadapter through a wizard and when the page reloads the initialize component would recreate it for you each time. Now that...
2
by: paul | last post by:
Hi I have a .NET V2.0 Web application that uses Oracle database./ I have started to run load tests and found that 23 Connections to Oracle open (invactive) for 2 concurrent users. I am...
0
MrMancunian
by: MrMancunian | last post by:
How to create a database connection without using wizards Introduction I've seen a lot of questions on the net about getting data from, and saving data to databases. Here's a little insight how...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.