Inserting Records Into an Access Database Using ASP.NET 2.0 – Tutorial

1) Open Visual Studio and create an ASP.NET website or create a new website
2) Open Access and create a database with at least one record
3) Save the file in the App_Data folder of the website
Ex. “\Visual Studio 2005\WebSites\web1-16\App_Data�?
4) Open the toolbox and from the Data section of the toolbox, drag “AccessDataSource�? on the blank page.
5) Configure the data source by left-clicking on the triangle on the data source and choose configure data source

DataSourceTriangle

6) Choose the database by browsing to it and selecting it.
7) Next configure the select statements by clicking “specify columns from table or view�? then clicking the “*�? button to select all attributes of the record. Then click the button to the right labeled “Advanced…�? to set up enable Insert, Update, and Delete features.
a. Click to select generate Insert, Update, and Delete Statements
b. Click to select use Optimistic Concurrency

8) Test your query then finish the wizard.
9) Next click on the DetailsView Control from the Data tools and drag it onto the page.
Image hosting by Photobucket

10) After you’ve configured the data source by selecting the Access Database on the details view, go to the Properties pane on the far right and set AutoGenerateDeleteButton, AutoGenerateEditButton, and AutoGenerateInsertButton to the value of True. By selecting True for those properties, you are allowing records to be deleted, edited, or inserted into the database.
Image hosting by PhotobucketImage hosting by Photobucket

11) Click on the Access data source, then in the Properties pane click on InsertQuery (Query) to open the Command and Parameter Editor.
12) Remove the primary key from the query (for this example ProfessorsID) and also the corresponding question mark. Also be sure to highlight ProfessorsID on the Parameter listing below the statement, then click the red X to remove it from the listing.
Image hosting by PhotobucketImage hosting by Photobucket

13)Then click OK.

14) Now you are ready to run the ASP.NET page complete with an interactive database



This entry was posted on Wednesday, February 1st, 2006 at 2:27 am and is filed under Programming. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

One Response to “Inserting Records Into an Access Database Using ASP.NET 2.0 – Tutorial”

  1.     Ben Says:

        February 17th, 2006 at 3:47 pm

    Thank you! This was exactly what I was looking for — simple, understandable and easy.

Leave a Reply