473,698 Members | 2,186 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AccessDataSourc e vs SqlDataSource Questions

I use an Access db in my application. So far I have been exclusively
working wtih the AccessDataSourc e controls to hook up to the db. I
know that Access db connections can also be established with
SqlDataSource.

What are the trade-offs between the AccessDataSourc e and SqlDataSource?

Also, I am confused about the connection state. What are the rules of
thumb for maintaining a db connection open vs closing it?

Thanks for any hints, Mark

Aug 3 '06 #1
4 2338
AccessDataSourc e class practically inherits from SqlDataSource. It's main
purpose is to make it easier (Access-like) to connect to the database, but
there's nothing that AccessDataSourc e can do but SqlDataSource couldn't
(actually it's opposite for example Access dbs protected with username or
password, must be connected with SqlDataSource, AccessDataSourc e cannot
handle them since it doesn't you to set the connection string)

Rules related to connection state are that you should open the connection as
late as possible (just before it's used) an close it as soon as possible
(after it's been used). You can use same connection for multiple db
operations (and keep connection open) if the operations are executed within
same method / scope so that connection isn't created muleiple times within
the scope, but there's no need to try to reduce instantiation of connections
for db operations with wider scope than that. For example say opening
connection in Page_Load and reusing it in all operations till Page_PreRender
runs, when you'd close the connection, you shouldn't do anything like that.
Connection pooling mechanism is very efficient, is also employed
automatically, and in fact is better controlling the resources than trying
to "help" the system with forcing connection to stay open is.

For more information about connection pooling,see:
http://msdn2.microsoft.com/en-us/library/8xx3tyca.aspx

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
<ms******@bluew in.chwrote in message
news:11******** **************@ m79g2000cwm.goo glegroups.com.. .
>I use an Access db in my application. So far I have been exclusively
working wtih the AccessDataSourc e controls to hook up to the db. I
know that Access db connections can also be established with
SqlDataSource.

What are the trade-offs between the AccessDataSourc e and SqlDataSource?

Also, I am confused about the connection state. What are the rules of
thumb for maintaining a db connection open vs closing it?

Thanks for any hints, Mark

Aug 3 '06 #2
Thanks for the feedback.

I kind of skimmed through the reference you provided, but as far as I
can judge it does not provide information about what takes place with
an AccessSource connection.

I would like to "unformize" db connections in my application by using a
single connection string. For instance, some pages already use ADO to
dynamically create the datasources with the web.config connection
string. Does it make sense to extend this to all dropdowns on the page
and forego thereby the datafile approach?

If so, how should I proceed? Define all drop down datasources in the
OnPageLoad event and close them after binding?

Another question. With an AccessDataSourc e how persistent is the
connection state? Does it automatically clear up after the data is
bound? There is no explicit disconnect function.

TIA for further precisions.

Aug 3 '06 #3
Thanks for the feedback.

I kind of skimmed through the reference you provided, but as far as I
can judge it does not provide information about what takes place with
an AccessSource connection.

I would like to "unformize" db connections in my application by using a
single connection string. For instance, some pages already use ADO to
dynamically create the datasources with the web.config connection
string. Does it make sense to extend this to all dropdowns on the page
and forego thereby the datafile approach?

If so, how should I proceed? Define all drop down datasources in the
OnPageLoad event and close them after binding?

Another question. With an AccessDataSourc e how persistent is the
connection state? Does it automatically clear up after the data is
bound? There is no explicit disconnect function.

TIA for further precisions.

Aug 3 '06 #4
AccessDataSourc e uses OleDb connection to Access database. That is classes
from System.Data.Ole Db namespace.

Data Source control handles all connection closing automatically except in
case you manually ask data reader from it (DataSourceMode is DataReader and
you manually call Select() yourself). In that case, connection can be closed
after data reader is closed.

Basically all you need to do is to specify ID of the data source control
into dataSourceID attribute/property of the databound control (DropDownList
in this case). With data bound controls by the way, you don't need to touch
the connection at all.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
<ms******@bluew in.chwrote in message
news:11******** **************@ s13g2000cwa.goo glegroups.com.. .
Thanks for the feedback.

I kind of skimmed through the reference you provided, but as far as I
can judge it does not provide information about what takes place with
an AccessSource connection.

I would like to "unformize" db connections in my application by using a
single connection string. For instance, some pages already use ADO to
dynamically create the datasources with the web.config connection
string. Does it make sense to extend this to all dropdowns on the page
and forego thereby the datafile approach?

If so, how should I proceed? Define all drop down datasources in the
OnPageLoad event and close them after binding?

Another question. With an AccessDataSourc e how persistent is the
connection state? Does it automatically clear up after the data is
bound? There is no explicit disconnect function.

TIA for further precisions.

Aug 5 '06 #5

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

Similar topics

1
1174
by: podong28 | last post by:
I want to connect mdb. not accessDataSource asp.net 2.0 nothing? I tried SqlDataSource. I Failed Thanks @podong28
4
3570
by: Luqman | last post by:
How can I display any field value in textbox of sqldatasource using VS.Net 2005 ? Say : Dim x as new AccessDataSource X.connectionstring="Data source="D:\mydb.mdb" X.Selectcommand="Select CompanyName from customers" Textbox1.text= ??? <-------- I need to display CompanyName Field in this textbox, how can I ?
0
1322
by: Luqman | last post by:
How can I display any field value in textbox of sqldatasource using VS.Net 2005 ? Say : Dim x as new AccessDataSource X.connectionstring="Data source="D:\mydb.mdb" X.Selectcommand="Select CompanyName from customers" Textbox1.text= ??? <-------- I need to display CompanyName Field in this textbox, how can I ?
0
1088
by: billmiami2 | last post by:
I'm trying to use the new 2.0 datasource controls to connect to a MS Access database. I'm using a machine that is running Windows XP Pro x64. I have no trouble connecting to SQL Server using the SQLDataSource control but when I try to connect to MS Access with the AccessDataSource control I get the following error: The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine. Unfortunately, I can't find a MS Jet 4.0...
0
3010
by: DC | last post by:
Why would this code give me the error "Could not load type System.Web.UI.WebControls.AccessDataSource from assembly System.Web, Version=1.0.5000.0" at line 16... <form id="form1" runat="server"> Line 15: <div> Line 16: <asp:AccessDataSource ID="AccessDataSource1" Runat="server" DataFile="data\pubs.mdb" Line 17: SelectCommand="select * from "
2
1993
by: djc | last post by:
1) I am wondering if I should be using an sqlDataSource object for my particular scenario. I need to loop through a listbox and perform an INSERT sql operation for each item. Could be a few or several items. The reason I'm wondering if I should use an SqlDataSource object is overhead. For example, prior to learning about the sqlDataSource I would just code the ado.net procedure myself. For example, create connection object, create and...
0
3422
by: mlfblom | last post by:
Hi, I know I am not the only one struggling with the following, but so far I have not seen a solution. Problem: I have an asp.net 2.0 web page with a gridview which is bound to an accessdatasource. In my code-behind I want to be able to set the selectcommand of the datasource to a specific SQL string based on a user's input to retrieve only certain records.
6
2042
by: Ken Fine | last post by:
I'm using SQLDataSource, which generates some kind of dataset, and then I attach that datasource to various data display controls such as DataList and repeater which loop through to the end of the data that was retrieved by the query. At times I may want the display control only to render some items in the set of data returned by SqlDataSource. There would be several scenarios: * render the second data item or third item in to the end...
2
2122
by: dorandoran | last post by:
I got this from http://www.codeproject.com/KB/aspnet/EditNestedGridView.aspx. I dont like using accessdatasource. What are my option? (what I really like is to create a class and create object in the form, my backend is sql server. Can anyone please please help?) Thanks <Do> private AccessDataSource ChildDataSource(string strCustometId, string strSort) { string strQRY = ""; AccessDataSource dsTemp = new...
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9157
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
9028
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
8895
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
8861
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
7728
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...
1
6518
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
2330
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.