October 2005 Entries



After spending many many many many - opps got stuck there - hours this last week trying to make a simple website xhtml 1.0 compatible across major browsers I have come to the point of wonder why we need to waste all this time.

The Story:

I managed to get the site looking good and working correctly under FireFox.  Then tried in IE and boom, there were several issues.  Fixed those and it rendered well on both, so I then tried Opera... Yep, looked like garbage.  One of the things I found was that for SOME reason Opera ads a margin or padding to their "form" tag on xhtml documents.  Setting that to zero solved that issue, but others still required more searching and fixing.

Now, I finally had a site that looked correctly in Opera, but when I checked, IE was whacked out.  This cycle continued hour after hour after hour after hour -- opps there I go again -- until I achieved a site that is xhtml 1.0 strict which happens to render correctly under these three browsers, however I am in fear to test them on any other browser ;)

We have had these battles as far back as I can remember with web development. It is not only that the standards are not implemented the same on all the browses, but that the standards themselves are flawed but it takes years to decades before anything gets changed.  This is flat out stupid!  Most people will be dead and buried before they get it right :)

Possible Answer:

Okay, that said, I am thinking that it is time to scrap the standards and even the browser and move on to something new.  Eeekk..  Yep, scrap it all and move on! 

Maybe it is time we take the good points we find in some of these standards and build something new.  For instance, a new application that is 100% compatible on all major platforms, allowing a form of website to be developed easily using more technology, where the final appearance is exactly what it is supposed to be and not just the browser's guess. Not hindered by "document" purists that believe it is all about documents and that the appearance it not important (or not too important).  The Real world, the appearance if very important along with functionality!

My first thoughts are that it would be great to have an application, a type of presentation virtual machine allowing very precise page designs.  Another major focus would be for input/output ability.  The HTML/Browser world is just about dead for the ability to use input/output devices such as mouse (scroll wheel, extra buttons, etc), tablets, touch screens, audio, printers, etc.  Would be nice to see something that gives more of an "application" type experience than a printed page type interface.

One main key to me at least, is to break out of the "browser" box and have an entirely new application without any legacy of the old browser world.  Would be great to have, if possible, two-way communications with the server, but may not be practical with firewalls and the likes.  Here, the primary focus is to come up with something new, using more of the technology sitting in our boxes, not just a text dump.

I am sure that if a group of people got together and thought it all out, they could come up with some ideas that would move us all into a new Internet Platform rather than just a browser application world.  Many people are connected on a 24/7 basis to the Internet, it is a shame that so little takes advantage of this!

People have to remember, they web as we know it, once did not exist, it was brought in by a simple file format and a special reader which later was know as the browser.  That does not just have to be history, it can happen again, but this time even better!

The main reason for this post is merely a reminder to myself, to give all this more thought in the near future.  It would be nice however, if a few others were interested and wanted to be involved.




Most people already know you can now write stored procedures in .NET with SQL Server 2005 (and Express), but there are other enhancements that many may miss.  Here are a few I have run into lately.

* XML data type.  XML is now a legitimate data type you can assign as a column in a table, return in a result set or pass as a parameter to a stored procedure.  It is now simple to use XML in SQL Server on about any level.

* Data type limits have been super-sized! Data types such as char, nchar, varchar, nvarchar and varbinany, can now specify "MAX" length storing values as large as 2 GB without the special handling used for text, ntext and image data types.  I have not checked, but I would think the 'like' and other functions would now be compatible with them, which was not possible with the nText, Text and image types.

* Goodbye to many temporary tables and ugly sub queries and enter 'Common Table Expressions'.  Now you can specify a temporary result set that lives for the duration of your select, update, delete or insert query and treat it as a table.  There are numerous times I could use such an animal, but one that really comes to mind is an example in the online books, using it to return a hierarchical list through recursion.

* The TOP operator is now usable with Insert, Update and Delete statements.  Not only that, but you can now use a variable for the value instead of it requiring a numeric text value and you can even specify as a percentage.  Oh, the number of times I had to build queries dynamically as a string in a stored procedure executing them only to specify a variable "TOP" parameter!

* New Ranking functions.  There are several new functions to handle ranking:

  • Rank()
  • Dense_Rank()
  • NTile(x)
  • Row_Number()

All of these are used with an "Over(order by...)" clause.  If you happen to have the "pubs" database on your server, here is a sample query:

 


use pubs

select 
  rank() over(order by qty) as rank, 
  dense_rank() over(order by qty) as Dense_Rank, 
  NTile(10) over(order by qty) as NTile, 
  Row_Number() over(order by qty) Row_Number, 
  Row_Number() over(partition by qty order by qty) Row_Number_P, 
  qty

from sales


The results are:

              

Rank

Dense_Rank

NTile

Row_Number

Row_Number_P

qty

1

1

1

1

1

3

2

2

1

2

1

5

3

3

1

3

1

10

3

3

2

4

2

10

3

3

2

5

3

10

6

4

3

6

1

15

6

4

3

7

2

15

6

4

4

8

3

15

9

5

4

9

1

20

9

5

5

10

2

20

9

5

5

11

3

20

9

5

6

12

4

20

13

6

6

13

1

25

13

6

7

14

2

25

13

6

7

15

3

25

13

6

8

16

4

25

17

7

8

17

1

30

18

8

9

18

1

35

19

9

9

19

1

40

20

10

10

20

1

50

21

11

10

21

1

75

First notice that Row_Number is in sequential order for the rows returned.  This one feature makes it very easy to add paging to results, but more on that in a moment.

As you can see, the Rank column skips ranking after ties as in Row_Number 3-5, there is a three-way tie for third place, but there is no 4 or 5 place since 4 and 5 tied with 3 for third place.  Same thing occurs in 9 place where there is a four-way tie, which skips places 10-12.

Dense_Rank does not skip numbers on ties.  I think this version is much more usable as I have never heard of rankings that are skipped on ties.

NTile spreads the rank out evenly throughout the range of 1 to (x) you specified.  In this example, it is 10, which spreads the values 1-10 throughout all the rows of the results.

In addition to these, you can use a "partition by" argument to the 'over' clause and gain a form of  “group by“, where it will reset the ranking numbers (Rank(), Dense_Rank(), NTitle(x), Row_Number())  based on the values of the "partition by" you specified.

As you can see in the Row_Number_P column, the value keeps resetting to one every time the qty changes.

* Paging!  Paging!  Paging!

All of this exploration today, came about because I was having a problem in a SQL 2000 database using a "Select into" with an "order by" for paging purposes.  This is not reliable in SQL Server 2000 and you need to use an alternative means to obtain the results.  Instead, I decided to see what it would be like under SQL 2005.

Much to my surprise, the problem code worked perfectly on SQL 2005 without change.  That was no good as I wanted to play with SQL Server 2005 a bit and explore the Rank functions.

I found paging is now quite easy.  Here is code to page the pubs.sales table:


use pubs
select stor_id, qty, title_ID
from

    select *, row_number() over(order by qty) as Row_Number 
    from sales
) as resultData
where Row_Number between 6 and 10


If we were paging the data at five rows per page, this would return page two of our data as specified by the rows "between 6 and 10".  This is easy to use, not sure about performance, but it is handy!

Let us now apply our new Common Table Expressions to the code, cleaning it up a bit:


use pubs
with StoreSales as
(
    select *, row_number() over(order by qty) as Row_Number
    from sales
)

select stor_id, qty, title_ID
from StoreSales
where Row_Number between 6 and 10


There is a lot of new power coming our way with the release of SQL Server 2005.  Features like these are just frosting on our cake!




The news is out, you can add a file to the root folder of your ASP.NET 2.0 called "app_offline.htm" and it will shut down the site and respond to all calls with the contents of the "app_offline.htm" file.  Now, how cool is that? 

http://weblogs.asp.net/scottgu/ archive/2005/10/06/426755.aspx

Normally, I keep a second website in IIS that is shut off until I need to do updates, which I would stop the real site and then start the offline message site until I was finished and then switch back.  With this new feature I no longer have to go through those hassles, all I have to do is keep a "app_offline.htm" file in my root directory and then rename it when I want to do maintenance and rename it back to a temp name when I am through.

I for sure, will make good use of this feature!




Somehow, I have missed news about the new IIS version 7 coming soon.  When I noticed a video about new version, I had to drag myself to watch, I just thought it would be a few security or performance enhancements, after all it is the web server and seems to be full featured already right?  Wrong!

http://channel9.msdn.com/Showpost.aspx?postid=109430

I was amazed at the new features they are adding to IIS.  If they added nothing but the ability to keep your site settings all in your web.config file, that would have been enough.  Microsoft is going far beyond that!

It was not long ago, I had a flaky page that did not seem to work correct under varying circumstances, which I spent a considerable amount of time trying to find the problem.  They new IIS's page tracking and notification features would have made that synch.

Microsoft is flat out amazing me lately with all this new technology and features that seem to have no end.  I can hardly wait for IIS 7 to be gold on my web server :)




Visual Studio 2005 Beta 2 has a huge number of cool features that can really make your life a lot easier.  On the other hand though, it is 'beta" software and contains numerous bugs and unconventional features that hopefully will vanish in the release.

During the process of converting one of my web applications over to this new technology, I ran into a number of problems that usually requiring searching the web for many hours trying to track down the problem and the fix.  Many of these problems will supposedly be fixed on release.

Today's problem is relating back to the new structure of the web project (or lack of) and attempting to publish your new wonderfully enhanced site to a production server.  Yikes!

VS2003 had a feature that you loved/hated to publish your site to a production server, "Copy Project".  This would allow you to copy on the files needed for the project to run and leave your source on your development machine where it belongs.  Oh, there were problems with this features and it would hang up at times or choke with an error, but at least a little persistence would get your files were they belonged.

I was excited to see the new "Copy Project" features in VS2005b2, but the excitement died quickly.  When you select this option, it simply gives you a window with a split screen to copy files from one machine to another (or synchronize them).  You have to select what goes and what does not.

For a moment, I thought, "I can deal with this!" and proceeded to try selecting files.  Then the brain bulb turned on in horror, how do I select the output DLLs that this new project-less project produces?  Yep, they are not there, it only has the source version to copy.  This is a problem since I do not want source code on the production server.  Surely, there is a method to select the compiled version…. NOPE!

Okay, so after search the net yet again and spending much more of my time, I noticed (by accident) that the Build menu had an option called "Publish <my local site name>".  Cool, this has to be the answer!  NOPE!

The "Publish" option can do what I desire to a point.  It will DELETE your ENTIRE production web server site.  It erases every file in you website folder and then copies the new ones over.  I am not sure "who" decided this would be a good feature, but it is not usable as is, unless the only files on your site belong to your one project and that your "web.config" is not different for your production server.  Yes, it will delete and replace your "web.config" file on the production server along with any changes you may have made to it such as connection strings and debugging mode!  Not only that, it will blow away (yes, delete: bye-bye) any virtual directories under that site!

It needed more research and after hours of browsing, there is still no answer.  The only way I have come up with to really handle this, is to "publish" the site to a local folder on the development machine then copy the files it produces to the production server manually to protect the "web.confing" and any other files or virtual directories on the production server.

I sure hope the release version of VS 2005 has an option for what is deleted and a method to keep the "web.config" file out of the mix.  It is fine for the initial push to the server to copy the "web.config", but after that point, it has to have many changes such as connection strings, debug mode, provider settings, etc.

It is hard to believe that after spending more than 15 hours searching around the net (this and a related problem over the last two days),  I cannot find a simple method to keep the "web.config" file safe when pushing the site from the development box to the production server without having to jump through hoops.  It appears most of this is by design, YIKES!

Anyway, there is a method to hide certain files on your development site such as the "BuildProviders" using the "IgnoreFileBuildProvider", but this seems only to block files of a specific file extension from the build.  Do not know how, or if it would effect the publishing of the site.

Still looking for answers ;)