Support us .Net Basics C# SQL ASP.NET ADO.NET MVC Slides C# Programs Subscribe Buy DVD

AccessDataSource in - Part 6

Suggested Videos 
Part 3 - Object datasource in
Part 4 - XMLDataSource in
Part 5 - Using XSLTTransform with xmldatasource control

If you want to retrieve data from Microsoft Access Database, and then display it in a gridview control, without writing a single line of code, AccessDataSource control can be used. Let's understand using AccessDataSource control with an example. Create an web application. Add a folder with name=Data to the project. Copy and paste your microsoft access database in the "Data" folder of the application.

Now drag and drop, AccessDataSource, on the webform. Click on the smart tag button of the "AccessDataSource" control, and then click on "Configure Data Source". Click on "Browse" button and select "Products.accdb" from "Data" folder. Now click "Next".

On "Configure the Select Statement" window, select the "table" and the "table columns". Click next. Here you will have the opportunity to "Test Query". Finally click "Finish".

Now, drag and drop a gridview control on the web form. Click on smart tag button on the gridview control, and select "AccessDataSource1" from "Choose Data Source" dropdownlist. 

Run the application, and notice that, data from access database is now displayed on the web form, as expected.

Please Note: You may get an error stating, The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine. If this is the case, you will need to install Microsoft office data connectivity components from the following link.

If your operating system is 64 bit, and MS Office is 64 bit, then install AccessDatabaseEngine_x64.exe version.
If your operating system is 64 bit, and MS Office is 32 bit, then install AccessDatabaseEngine.exe version.

If you still have the issue, please make sure, Enable 32 bit applications property is set to true, for the application pool that is running your web application.

No comments:

Post a Comment

If you like this website, please share with your friends on facebook and Google+ and recommend us on google using the g+1 button on the top right hand corner.