13.07.2015 Views

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 12: ADO.<strong>NET</strong>: Hello Database 301Once you have tested the application and gotten the expected output, try changingthe query to test different <strong>com</strong>binations. Remember, the code is just a string of SQLqueries.Entering Data from a Web SiteOne of the most important aspects of working with ADO.<strong>NET</strong> is its ability tostore data entered from anywhere on the Internet. E-business is dependent on remoteshoppers entering orders that can be stored for later retrieval for order processing. Thatmeans any e-business application is going to require a database that can accept inputfrom someone other than the site administrator who sits with Visual Studio 2008 andenters data.This section examines the different ways to enter data from a web site. Starting withbasic code to enter data when the page loads to practical Web forms that let the user enterthe data directly, this section gets you started on ways to add records to your database fromthe Web.Automatic Data EntrySometimes you may want certain fields to be automatically filled. This is usually the casewhere you have a unique ID for each record. In the example table you have seen in thischapter, the SupID field is supposed to have unique values, but the way they are set up,somebody has to add a unique value. It could be the administrator, but such an entry systemlimits the entry process to a single person working from a list. Wouldn’t it be better to havethe unique ID value be entered no matter who enters the values for the other fields? Toquote Curly, soitenly!At this stage not too many entries have been made in the database table, so itshould not be too difficult to make the necessary changes to set up an automatic uniquevalue to be entered into the SupID field. The following steps guide you through thisprocess:1. In the Server Explorer open the VoteNow database in the Tables folder, and thendouble-click the Supporters table to open the Table Definition window.2. Click on the Data Type cell in the SupID row. In the pop-up window, change thedata type from nchar(10) to int. You need some kind of integer for automaticincrement.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!