Last post Mar 19, 2008 07:35 AM by Mikesdotnetting
Feb 12, 2008 02:58 PM|vwgolfman|LINK
There appear to be two Data Source controls for extracting data from an Access Database.
Please can somebody tell me the difference between these two....
SqlDataSource > Microsoft Access Database File (Use this selection to connect to a Microsoft Access database file through the .NET Framework Data Provider for OLE DB).
Thank you :)
Feb 12, 2008 03:22 PM|Mikesdotnetting|LINK
AccessDataSource exposes only a DataFile property, which means you have to set the path and name of the database every time you use the control. This means that if the file name or path changes, you have to change every control in the application. SqlDataSource
takes a connection string, which can be stored in one place, liek the web.config. If it needs changing, you only have to change it in one place. I never see the point in using the AccessDataSource control.
Mar 19, 2008 06:56 AM|vwgolfman|LINK
Resurrecting an old thread here but can anybody else expand on this please?
Is security tighter using the SqlDataSource?
If the AccessDataSource was designed purely for accessing an Access Database and I was using in Access Database wouldn't I be better of using that control?
Mar 19, 2008 07:35 AM|Mikesdotnetting|LINK
The main difference between the controls is that the AccessDataSource control will only accept the path of an mdb file as a DataFile value. Internally, it then uses the Jet OleDb provider to do it's thing. Now, there's nothing wrong with this, except that
each datasource control throughout your application needs to have the path set individually. I suppose you could get round this by storing the path in one place as a string, then applying that string to the DataFile property in your code behind, but that
seems a bit of a bodge to me. The SqlDataSource control accepts a connection string, and is designed to work with any OleDb compliant database, such as Sql Server, Access, Oracle, DBase etc. It will be as good as the provider that is specified in the connection
string. It's a cleaner approach in my view to store the connection string in one place (the web.config) and reference that with each control. It's really a question of how to best manage constant strings in applications. I prefer not to have them sprinkled
about - even thought the likelihood of me ever needing to change them is remote.
Internally, both controls operate in exactly the same way. They both derive from DataSourceControl, which implements IDataSource. That means that they are as performant and safe in terms of security as eachother. So, apart from the DataFile/Connection String
difference, they are equally as good for working with Access. And that just leaves me feeling that the AccessDataSource control is superfluous.