473,699 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1210
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**********@g mail.comwrote in message
news:11******** *************@z 28g2000prd.goog legroups.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(S qlConnStr))
{
using (SqlCommand SqlComm = new SqlCommand(strS QL, 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
2408
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 visitors to my Web site can access my database through my Web site at one time? Or does this mean that in my code I can only use 50 connections? and like
0
1512
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 selected ALL, I am never able to refresh the data to the DUPS subset of data. Every click returns ALL records. If I choose DUPS the first time it works once, but once I do ALL I can no longer get just the DUPS.
2
1297
by: Vik | last post by:
Is it possible to loop through all dataadapters on page? Thanks
4
1277
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 the adapter with an open connection the connection will continue to be open after the adapter is done." My DataLayer makes extensive use of DataAdapters to fill DataSets, and
2
932
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 uses data need its own connection?
2
1668
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 other is a String. Currently they both work as I like and I can get my data as I want. What I'm intersted in is seeing HOW I do a Global search for both cases. Here are my two issues: ISSUE 1:
0
1055
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 many others but I can't find any help on general knowledge on how to deal with converted projects. Can anyone point me to the hidden help? Thanks, T
0
979
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 the initialize component in 2.0 is only called once when the application loads each time a call back is done or the page load is called the dataadapter is null. Is there anyway that I don't have to create the dataadapter manually in the pageload? ...
2
5643
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 using a database pool (max 50), which gets filled pretty quickly, I have check the code to ensure that connections have been closed, which seems to be OK.
0
4752
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 to do that using .NET code. I prefer using code instead of wizards, because you are completely in charge of connections. This article is written for both Visual Basic.NET 2005 and C# 2005 and will discuss how to use an MS Sql database. OleDB works...
0
9174
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9035
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8884
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7751
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5875
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.