Tuesday, August 7, 2007

First Project - Office Phone Book

The Office Phone Book Project

This project has been on my desk for months. I keep putting it off becuase I want it to be a good test of ASP.NET database driven web site. The database in phonebook data is already in an Access 2000 MDB.

I start Microsoft Web Developer 2005 Express Edition or "Web Developer" for short. From the main screen I create a new Web Site. Location listed below.
"My Documents\Visual Studio 2005\Projects\PhoneBook" and I select ASP.NET web site. Web Developer then creates the following files and folders.

Phonebook\App_Data
Default.aspx
Default.aspx.vb
PhoneBook.sln
web.config
PhoneBook\App_Data\Aspnetdb.mdf
PhoneBook\App_Data\aspnetdb_log.ldf
PhoneBook\App_Data\web.config

I copied our PhoneList.mdb file that contains all of our phone book data from our network to my workstation and placed it in the following location.
PhoneBook\App_Data\phonelist.mdb

(1) Now in my Web Developer I drug a GridView onto my Default.aspx work serface.
(2) I then selected the GridView Tasks and under 'choose data source' I selected
(3) I then selected Access Database as the database type and let the Developer specify the default ID for the data source as 'AccessDataSource1'
(4) Then I selected the path to the Access 2000 database phonelist file. The location is; '~/App_Data/PhoneList.mdb'.
(5) Now the wizard wants to know what data I would like to use and from what table. I select the PhoneListTable and then select the following fields.
[ID] - This is the autonumber index field in my table.
[DID_Number]
[FirstName]
[LastName]
[ShowInPhoneList] = This is a boolian Y/N check box.
(6) I then click on the Advance Tab. Since I selected an index field [ID] The developer is going to allow me to 'Generate INSERT, UPDATE, and DELETE Statements' So I check this box. I also check the box 'Use Optimistic Concurrancy' so that updates by mutiple users in the same record would be possible without data collisions.
(7) After clicking on NEXT I test the query and find that my data does appear.
(8) I am now taken back to the GridView which has been updated to now show the fields that I selected above. I now check 'Enable Paging', 'Enable Sorting' and 'Enable Editing'.

I am now ready to test my database web page. I click on RUN to test my application. I do not get any errors in my Web Developer and the web page with my data displayed in a table works perfectly. However when I click on Edit a record and try editing or adding data to any field and the click on Save nothing happens.

So my question is what went wrong. I tested the connection and that passed. The web page displays the data with no problem. So why can I not update a record?

I stop the application and then click on the Database Explorer. I right click on PhoneBookTable and select Display Data.

The Web Developer now shows a complete list of my data. I test editing a field and it works perfectly within the Web Developer. But from a web page nothing happens when I edit a record. The record shows the data changes in the field but when I click on UPDATE the data disapears or reverts back to the original data.

No comments: