Archive for October, 2007

Fedora web server - CHAPTER 1 Data Sources and

Wednesday, October 31st, 2007

CHAPTER 1 Data Sources and the Web Look around you. No really, look around you. In the past 30 years, computers have taken over from the filing cabinets of the world to become the (almost) universal way people store and look up information. Would you rather spend five minutes rifling through some badly organized stack of paper for the name of a client or the price of a book, or spend ten seconds typing in a search query on a computer and getting the desired information back immediately? I thought so the computer wins every time. It s not just in the office that data-driven Web sites have proven popular. Server-side technologies now allow people to hook electronic data sources databases, spreadsheets, Extensible Markup Language (XML) files, Windows services, and more to Web sites. This means that today s World Wide Web is a place of dynamic, data-driven Web sites, rather than the collections of static Hypertext Markup Language (HTML) pages it once was. Regardless of whether you develop your Web sites with Active Server Pages (ASP), ASP.NET, PHP, JavaServer Pages (JSP), or one of numerous other technologies, you can use a data source to interact with your users, giving them the information they want to see and safely storing how they want to see it next time. E-commerce Web sites, such as Amazon and eBay, use databases to provide customers with product information, recommendations, and wish lists, and to store feedback and orders. Portal Web sites use databases to store articles and user settings, so users don t need to reset them each time they visit the Web site. How you choose to use data in your Web site is up to you. Whatever your goals are for your data-driven Web site, this book will give you the tools you ll need to accomplish them. In this chapter, you ll look at the world of data-driven Web sites from 50,000 feet, so that by the time you finish it, you ll at least have a rough knowledge of how things hook together. You ll spend the rest of the book parachuting down to the ground, espying the exact details as you get closer. Up here in the blue sky of Chapter 1, you ll learn the following: Why data-driven Web sites are such a good idea How a data-driven page actually works The different sources of data you can use with ASP.NET Web sites How ADO.NET is the glue that joins data sources and ASP.NET Web sites How to build your first data-driven page
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.

INTRODUCTION xxvii Chapter 7 (Web design tools) builds on Chapter

Wednesday, October 31st, 2007

INTRODUCTION xxvii Chapter 7 builds on Chapter 6 and shows how you can bind a full table of values to table- aware Web controls, again using a DataReader object, a DataSet, or a SqlDataSource. Chapter 8 shows how you can use form controls and the Command object or a DataSet to create, update, and delete data. Chapter 9 looks at updating the database using the GridView, DetailsView, and FormView controls in conjunction with a SqlDataSource to create, update, and delete data. Chapter 10 describes stored procedures and how to use them. Stored procedures are queries stored in a database that, depending on your choice of database, may run faster than queries sent over a connection to a database from the ASP.NET page. Chapter 11 looks at the Data Definition Language (DDL), which allows you to create, modify, and delete databases. Chapter 12 explores four issues that you ll come across when building your data-aware pages: concurrency, caching, transactions, and multiple result sets. Chapter 13 presents an overview of designing a database-driven Web site from scratch. In particular, it covers picking the right data source for your Web site and the right design for your database. It also discusses code style, performance, error handling, debugging, and maintenance. Finally, the book has four appendices for your reference. In order, they cover the installation of the software used; the data types used by SQL Server 2005, MySQL 5.0, and Microsoft Access; the syntax for all the SQL queries used in this book; and the contents of the sample databases used in the examples. I hope you enjoy the book and get as much out of reading it as I did out of writing it. If you do get truly stuck or find errors in the book, please let me know via support@apress.com, quoting this book s ISBN (577-7).
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.

Professional web hosting - xxvi INTRODUCTION The only other things you ll need

Tuesday, October 30th, 2007

xxvi INTRODUCTION The only other things you ll need are a computer that runs Windows 2000, Windows XP, or Windows 2003 and has a fast enough connection to the Internet. You may need to download several items to work through this book, as follows: .NET 2.0 (22.4MB) Visual Web Developer Express Edition (43MB) SQL Server 2005 Express Edition (53.5MB), along with SQL Server Management Studio Express (30MB) MySQL 5.0 (16.8MB), along with MySQL Query Browser (5.1MB), Connector/ODBC (2.3MB), and Connector/NET (545KB). This book also covers using Microsoft Access as a database. But unless you have an MSDN subscription, you ll need to buy this as part of Microsoft Office. Of course, working through the book with just one database SQL Server 2005, for instance is fine. I m just covering all the bases by presenting three of the most commonly used databases. What This Book Contains The chapters in the book are broadly divided into three sections: introductory material (Chapters 1 and 2), database-access techniques (Chapters 3 12), and a final chapter looking at some real-world issues (Chapter 13). Here s a quick rundown: Chapter 1 takes a high-level overview of how data-driven Web sites work, how ASP.NET and ADO.NET let them work, and what you can use as a source of data for your Web sites. Chapter 2 takes a similarly high-level overview of databases, which are the typical data sources for Web sites. It covers the components that make up a database, how a database stores and gives meaning to data, and a few basic rules for storing data in a database. Chapter 3 describes how to connect your ASP.NET page to a database by writing a minimum amount of code using the SqlDataSource. Chapter 4 covers how to connect your ASP.NET page to a database using code to perform the job of the SqlDataSource from the previous chapter. It presents some of the common database queries that will return data for display on a page. It also looks at how you actually send those queries to the database. Chapter 5 discusses how you handle the results of your queries in the page using a DataReader object, which is fast and direct but has drawbacks. It compares the DataReader with a DataSet, which gives you a lot more flexibility with the results of your data, but is somewhat slower and bulkier than a DataReader. Chapter 6 starts your look at how to bind data ( plug in data to a page) from a DataReader object, a DataSet, or a SqlDataSource to Web controls on the page. This chapter looks at binding to individual Web controls, as well as binding a list of results to list-aware Web controls.
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

Introduction Welcome to the introduction. From this point (Photoshop web design)

Tuesday, October 30th, 2007

Introduction Welcome to the introduction. From this point on, you ll discover the amazing world of ADO.NET, inanimate computer desks, late-night coding sessions, evil bugs, functions, methods, properties, and data. Seriously though, welcome to the world of databases in ASP.NET. The idea for this kind of book isn t new, but if you re trying to learn something for the first time, having it constantly spelled out to you in a stodgy, primary-school-history-teacher-learnthese- dates-by-rote style probably won t help. Therefore, you ll find one joke per 50 pages to this book to break up the monotony. Actually, a confession here: I studiously spent several years avoiding anything to do with databases because, despite my love of things techie, I always perceived them to be even more techie than other server products and operating systems. Come on, system administrators defer to database administrators, who have to wear white lab coats, have foreheads the size of Mount Rushmore to hold their huge brains, and speak in some additional language only they understand to commune directly with their charges, don t they? Of course not. Thanks to a little nudging and handholding, I can now build data-driven Web sites. These Web sites use databases and other sources of information to define what they present to a user and how they present it, and to learn how the user would like it to work. With any luck, by the time you ve worked through this book, you ll be able to do the same (without the need to stand stubbornly in the corner for several years muttering something about databases being scary and too techie). How to Use This Book This book is designed as your all-in-one introduction to the world of building data-driven Web sites using ASP.NET and ADO.NET. It s intended to be read from beginning to end, rather than by dipping in at random points, as you may do with other, more reference-type books. You may have come across databases already in other books, but this one assumes you really have been sitting at the bottom of a well for the past five years and know nothing at all about databases. It does, however, assume that while you were in your well, you had a book teaching you some ASP.NET and a computer on which to write your first ASP.NET pages. You can download all the code and sample databases for this book from the Source Code section of the Apress Web site at http://www.apress.com. However, many of the examples are short enough that they can be typed in, and I hope you decide to do this, because it will help you to learn and remember the material.
Check Tomcat Web Hosting services for best quality webspace to host your web application.

Set Relations Using Bit Vectors Set relations become

Sunday, October 14th, 2007

Most popular web site - @seen_twice == keys %$set2; return ‘proper superset’ if @seen_twice == keys %$set2; return ‘proper subset’ if @seen_twice == keys %$set1; # ’superset’, ’subset never returned explicitly. return ‘proper intersect’; } Here is

Saturday, October 13th, 2007

@seen_twice == keys %$set2; return ‘proper superset’ if @seen_twice == keys %$set2; return ‘proper subset’ if @seen_twice == keys %$set1; # ’superset’, ’subset never returned explicitly. return ‘proper intersect’; } Here is how compare() might be used:break %Canines = %Canidae = %Felines = %BigCats = %Carnivores = (); @Canines{ qw(fox wolf) } = ( ); @Canidae{ qw(fox wolf) } = ( ); Page 225 @Felines{ qw(cat tiger lion) } = ( ); @BigCats{ qw(tiger lion) } = ( ); @Carnivores{ qw(wolf tiger lion badger seal) } = ( ); printf “Canines cmp Canidae = %sn”, compare(%Canines, %Canidae); Printf “Canines cmp Felines = %sn”, compare(%Canines, %Felines); printf “Canines cmp Carnivores = %sn”, compare(%Canines, %Carnivores); printf “carnivores cmp Canines = %sn”, compare(%Carnivores,%Canines); printf “Felines cmp BigCats = %sn”, compare(%Felines, %BigCats); printf “Bigcats cmp Felines = %sn”, compare(%Bigcats, %Felines); and how this will look: Canines cmp Canidae = equal Canines cmp Felines = disjoint Canines cmp Carnivores = proper intersect Carnivores cmp Canines = proper intersect Felines cmp BigCats = proper superset BigCats cmp Felines = proper subset We can build the tests on top of this comparison routine. For example: sub are_disjoint ($$) { return compare( $_[0], $_[1] ) eq ‘disjoint’; } Because superset and subset are never returned explicitly, testing for nonproper super/subsetness actually means testing both for proper super/subsetness and for equality: sub is_subset ($$) { my $cmp = compare{ $_[0], $_[1] ); return $cmp eq ‘proper subset’ or $cmp eq ‘equal’; } Similarly, testing for an intersection requires you to check for all the following: proper intersect, proper subset, and equal. You can more easily check for disjoint; if the sets are not disjoint, they must intersect.
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.

is contained by Carnivores, and (Web host 4 life) Carnivores contains Felines.

Saturday, October 13th, 2007

is contained by Carnivores, and Carnivores contains Felines. Carnivores is a superset All that Felines has, Carnivores has too, and the sets might even be of Felines. identical. Carnivores is a proper Carnivores has everything Felines has, and Carnivores also has superset of Felines. members of its own the sets are not identical. Carnivores contains Felines, and Felines is contained by Carnivores. (table continued on next page) Page 224 (table continued from previous page) Relation Meaning Canines is equal to Canines and Canidae are identical. Canidae. a In case you are wondering, foxes, though physiologically carnivores, are omnivores in practice. Summarizing: a subset of a set S is a set that has some of the members of S but not all (if it is to be a proper subset). It may even have none of the members: the null set is a subset of every set. A superset of a set S is a set that has all of the members of S; to be a proper superset, it also has to have extra members of its own. Every set is its own subset and superset. In Figure 6-13, Canidae is both a subset and superset of Canines but not a proper subset or a proper superset because the sets happen to be identical. Canines and Carnivores are neither subsets nor supersets to each other. Because sets can overlap like this, please don’t try arranging them with sort(), unless you are fond of endless recursion. Only in some cases (equality, proper subsetness, and proper supersetness) can sets be ordered linearly. Intersections introduce cyclic rankings, making a sort meaningless. Set Relations Using Hashes The most intuitive way to compare sets in Perl is to count how many times each member appears in each set. As for the result of the comparison, we cannot return simply numbers as when comparing numbers or strings (< 0 for less than, 0 for equal, > 0 for greater than) because of the disjoint and properly intersecting cases. We will return a string instead. sub compare ($$) { my ($set1, $set2) = @_; my @seen_twice = grep { exists $set1->{ $_ } } keys %$set2; return ‘disjoint’ unless @seen_twice; return ‘equal’ if @seen_twice == keys %$set1 &&
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.

Web hosting support - $Domesticated = hash_set_to_bit_vector( %Domesticated, $numbers ); sub count_bit_vector_members { return unpack “%32b*”, $_[0]; } print count_bit_vector_members($Domesticated), “n”; Both will print

Friday, October 12th, 2007

$Domesticated = hash_set_to_bit_vector( %Domesticated, $numbers ); sub count_bit_vector_members { return unpack “%32b*”, $_[0]; } print count_bit_vector_members($Domesticated), “n”; Both will print 3.break Page 223 Set Relations Do all the web documents that mention camels also mention Perl? Or vice versa? Sets can be compared. However, the situation is trickier than with numbers because sets can overlap and numbers can’t. Numbers have a magnitude; sets don’t. Despite this, we can still define similar relationships between sets: the set of all the Californian beach bums is obviously contained within the set of all the Californians therefore, Californian beach bums are a subset of Californians (and Californians are a superset of Californian beach bums). To depict the different set relations, Figure 6-13 and the corresponding table illustrate some sample sets. You will have to imagine the sets Canines and Canidae as two separate but identical sets. For illustrative purposes we draw them just a little bit apart in Figure 6-13. Figure 6-13. Set relations The possible cases for sets are the following:break Relation Meaning Canines is disjoint from Felines. Canines (properly) intersects Carnivores. Felines is a subset of Carnivores. Felines is a proper subset of Carnivores. Canines and Felines have no common members. In other words, their intersection is the null set. Canines and Carnivores have some common members. With “properly,” each set must have some members of its own.a Carnivores has everything Felines has, and the sets might even be identical. All that Felines has, Carnivores has too, and Carnivores has additional members of its own the sets are not identical. Felines is contained by Carnivores, and Carnivores contains Felines
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.

symmetric difference look in sets (Business web site) and binary logic.break

Friday, October 12th, 2007

symmetric difference look in sets and binary logic.break Figure 6-7. Set differences as bit vectors Page 222 Here is how our code might be used: # Binary mask is AND with NOT. $difference = $Canines & ~$Domesticated; # Binary XOR. $symmetric_difference = $Canines ^ $Domesticated; print “difference = “, “@{[keys %{bit_vector_to_hash_set( $difference, $names )}]}n”; print “symmetric_difference = “, “@{[keys %{bit_vector_to_hash_set( $symmetric_difference, $names )}]}n”; and this is what is should print (again, beware the pseudorandom ordering given by hashes): wolf wolf cat horse Counting Set Elements Counting the number of members in a set is straightforward for sets stored either as hash references: @Domesticated{ qw(dog cat horse) } = ( ); sub count_members { return scalar keys %{ $_[ 0 ] }; } print count_members( %Domesticated ), “n”; or as bit vectors: @Domesticated{ qw(dog cat horse) } = ( ); ( $size, $numbers, $names ) = members_to_numbers( %Domesticated );
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.

return %difference; } An easy way to implement symmetric (Web domain)

Thursday, October 11th, 2007

return %difference; } An easy way to implement symmetric difference is to count the times a member is present in the sets and then take only those members occurring an odd number of times. We could have used counting to compute set intersection. The required number of times would equal the number of the sets. Union could also be implemented by counting, but that would be a bit wasteful because all we care about is whether the number of appearances is zero.break sub symmetric_difference { my %symmetric_difference; my ( $element, $set ); Page 221 while ( defined ( $set = shift( @_ ) ) ) { while ( defined ( $element = each %$set ) ) { $symmetric_difference{ $element }++; } } delete @symmetric_difference{ grep( ( $symmetric_difference{ $_ } & 1 ) == 0, keys %symmetric_difference) }; return %symmetric_difference; } @Polar{ qw(polar_bear penguin) } = (); @Bear{ qw(polar_bear brown_bear) } = (); @Bird{ qw(penguin condor) } = (); $SymmDiff_Polar_Bear_Bird = symmetric_difference( %Polar, %Bear, %Bird ); print join(” “, keys %{ $SymmDiff_Polar_Bear_Bird }), “n”; This will output: brown_bear condor Notice how we test for evenness: an element is even if a binary ANDwith 1 equals zero. The more standard (but often slightly slower) mathematical way is computing modulo 2: ( $symmetric_difference{ $_ } % 2 ) == 1 This will be true if $symmetric_difference{ $_ }is odd. Set Differences Using Bit Vectors The difference and symmetric difference are bit mask (an ANDwith a NOT) and bit XORon the string scalars (bit vectors) representing the sets. Figure 6-12 illustrates how set difference and
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.