Quarksoft Blog

This is where we post useful information for everyone. Lots of it is technical, but some can be used by anyone.

ASP.NET AJAX Control Toolkit Samples

Most of you probably have already experimented with the Control Toolkit, but just in case you never ran across it, take a look at these Toolkit samples

If you have any questions about them, drop me a comment here.

Calculating Age in T-SQL

Here’s a decent article on calculating the age of a person (or anything else) written by Lynn Pettis.  Discusses some pitfalls with leap years.

Using and Managing SQL Server Aliases

I know that not many people I have met in my SQL Server experience have used SQL Aliases.  In many ways it is one of the most useful features of SQL Server.   Roman Rehak wrote a great article about SQL Server Aliases.  You have to be registered to see the full article, but some of the highlights are discussed below.

Creating an alias all depends on which client tools are installed on the computer you are using.  Here are the common methods for running the SQL Client Configuration Tool:

  • If SQL Server 2000 client tools are installed, use the SQL Client Network Utility and select the Alias tab.
  • If SQL Server 2005 client tools are installed, use the SQL Server Configuration Manager and expand the SQL Native Client Configuration node to find the node for Aliases.
  • If you do not have any client tools installed, you can still get at the Client Network Utility by executing “cliconfg” from any command prompt.

Aliases are useful in the following scenarios:

  • Create an alias that is a friendlier name than the server name itself.
  • In a Development/QA/Production environment.  Using aliases allow you to keep the code base across your servers the same without having to change source code (sort of related to the last bullet).
  • Enforce the use of a particular protocol.  If you get the “Cannot generate SSPI context” error you can try creating an alias to force the use of the Named Pipes.
  • A distributed environment with multiple servers that reference each other using the Linked Servers feature.  You can define the linked servers with the aliases instead of the actual names.  This makes future moving of databases and such much easier since you will not need to chnage the linked server names in your code.
  • In a high-availability environment to allow you to quickly change the server without changing all your code (such as web applications and such).

I’m sure there are other useful reasons to use aliases, but that covers a few of them that show the power of the alias function.

If you have any other good ideas, please comment on the post.

Great Script for Accessing IIS Configuration Properties

Need to extract information from IIS such as IP Addresses, Host Headers, Log Directories and lots more. This great little script from David Wang does a great job of this.  It saved me hours and hours of work going through all my IIS servers manually.

Thanks David!

Useful way to reformat an ASP.NET File Upload control

The guys over at QuirksMode.org have come up with an interesting way to get around the default styling of a File Upload control See the details here:

http://www.quirksmode.org/dom/inputfile.html

So what do you do with all those IIS log files?

You are responsible for one or more Windows web servers and you have all these IIS log files that you want to make some sense out of.   If you have some basic SQL skills Microsoft is making available a utility called LogParser which does a great job getting in there and allowing you to query the files directly using some basic SQL syntax.   The feature I like the best is the ability to convert the data into a SQL table for manipulation via T-SQL.

Here is a sample of what I did (this would all go on a single line)

c:\”program files”\”log parser 2.2″\LogParser -iCheckPoint:myCheckPoint.lpc -o:SQL -server:localhost -database:IISLogs -createtable:ON “SELECT * FROM ex0810*.log TO IISLogs”

This short command line will read in all log files that start with ex0810 and import them into a table called IISLogs.  It will also create a checkpoint file so that if you run the command again it will not import records that have already been imported.

How cool is that?

Once all the importing is done you can leverage the SQL tables using whatever methods you need to.

If you need any help with stuff, send us a note at support at quarksoft.com.

Outlook 2007 Preview Pane made useful…

I finally had upgraded to Outlook 2007 about a month ago and one of the features I found myself using a lot was the Preview feature for attachments. It was great for the PDF and the typical office documents, but there were no preview handlers for files such as WAV. I have a VOIP line that emails me the voice mail messages that have been left so having a WAV previewer would be really useful for me.

During my search for such a feature I ran across a great utility from Gil Azar (and in his post gives credit to lots of others for their help). You can download the ultimate Outlook 2007 preview handler from his site.

If you are interested in some of the technical details Gil discusses them on his page and provides some really great links.

I’ve included parts of Gil’s original post just in case his site disappears one day.

A self-extracting installer, which silently installs Stephen Toub’s MSDN Magazine Managed Preview Handler Framework and Gil’s small addition, can be downloaded here

Command Line FTP Client with PASV support

I ran into a problem scheduling the transfer of a file via FTP today.  The server was behind a firewall that required me to use PASV FTP support.  Unfortunately the command line version of FTP that comes with Windows 2003 was not able to support this configuration (at least I could not figure out how to make it support it).

In trying to figure out a solution to this issue I ran across NcFTP.  This is primarily a *nix based FTP tool (both server and client), but it has a Windows command line version of FTP that proved to be just the tool I needed.  You can download the Windows version of the client or if you prefer they have lots of *nix flavors.

Easy method to download a portion of a web site

I have this client that posted several hundred files on their internal web site that I needed to download to my laptop for testing purposes.  I started downloading them one by one and thought that there must be a better way without installing some big application to do this.  With a little Google searching I found a great open source utility called wget that provides everything I needed from a command line (which had the added bonus of being able to easily script it).

An example of the command to recursively download a web site is shown below:

wget -l2 -r -k http://www.siteyouwanttoget.com/folder1

  • The -l parameter tells the software how many levels to download (I only needed 2 levels deep in my example)
  • The -r parameter tells it to download recursively
  • The -k parameter tell is to convert non-relative links into relative ones so that there will not be any dependencies on the original site.

So there you have it. One simple, small 162Kb EXE that does exactly what I needed (it also does ALOT more than this). Have Fun!

ASP.NET Session State in SQL Server

There are lots of places to get information about putting the Session State into a SQL Server database instead of in-memory. The information I have found most useful is the utility aspnet_regsql.exe. It performs a bunch of different tasks for ASP.NET and interaction with SQL Server and the membership interfaces.

For example if you want to get session persisted across SQL Server reboots you can issue this command:

aspnet_regsql.exe -ssadd -sstype p -E -S <servername>

The sstype p is the option that allows for the state to be persisted. You can execute aspnet_regsql.exe -?