473,386 Members | 1,673 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,386 software developers and data experts.

AccessDataSource vs SqlDataSource Questions

I use an Access db in my application. So far I have been exclusively
working wtih the AccessDataSource 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 AccessDataSource 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 2321
AccessDataSource 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 AccessDataSource can do but SqlDataSource couldn't
(actually it's opposite for example Access dbs protected with username or
password, must be connected with SqlDataSource, AccessDataSource 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******@bluewin.chwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
>I use an Access db in my application. So far I have been exclusively
working wtih the AccessDataSource 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 AccessDataSource 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 AccessDataSource 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 AccessDataSource 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
AccessDataSource uses OleDb connection to Access database. That is classes
from System.Data.OleDb 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******@bluewin.chwrote in message
news:11**********************@s13g2000cwa.googlegr oups.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 AccessDataSource 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
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
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...
0
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...
0
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...
0
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"...
2
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...
0
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...
6
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...
2
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...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.