Justin Cooney

Web Development Tips and Examples

  • Sometimes while developing a tool, a developer needs to pass a list of values with a variable size to their database. There are several ways of doing so, one of which involves passing the list in XML format.

    The introduction of SQL Server 2005 offered the use of XML datatypes, which had not existed in previous versions of SQL Server. The good thing about the XML datatype is that it is not just good for storing information in XML format, but also has advantages such as being fully query-able similar to a database table.

    As you look through this example, please feel free to check out other articles I have written for more SQL Tips

    Here are the three main ways of passing lists of parameters to the different versions of SQL Server

    A big benefit of the XML datatype is the ability to pass lists of items to stored procedures as XML format parameters. In SQL Server 2000 one would have to pass a list of parameters as a String that would then need to be parsed into its components in the Stored Procedure. This a tedious process that could easily introduce parsing errors. Subsequent versions of SQL Server have added extra ways in which to pass information lists to Stored Procedures:

    1. As a character-separated list contained in a String (VARCHAR) variable – SQL Server 2000 +
    2. As an XML variable – SQL Server 2005 +
    3. As a table variable – SQL Server 2008 +

    As you can see from the list above, the methods of passing lists to stored procedures have increased in number over the last few iterations of SQL Server. The catch of course is that as a developer you will need to adapt your code to whichever instance of SQL Server your project is based on.

    (more…)

  • If you need to quickly and easily generate PDF documents from ASP.NET, then the iTextSharp library for .NET is very convenient. To install and start using iTextSharp, you can download the zipped reference files from the SourceForge Web site and then add them to your Visual Studio project the same way as you would do with any other third party library file.

    The latest version of iTextSharp has deprecated the older HTMLWorker object in favor of the newer XMLWorkerHelper object. This is good news for any developer who likes to use CSS formatting. Although the CSS support is still basic, it is a definite step up from the earlier version of the object which did not support CSS at all. For example, the new object allows a number of important behaviors such as PDF page breaks that were impossible to do using the older object.

    To make use of the XMLWorkerHelper object you will need to reference two DLL files in your Visual Studio project. These are:

    1. itextsharp.dll
    2. itextsharp.xmlworker.dll

    Once you have referenced these two libraries you are ready to start coding.

    In this article I provide a fully working example in both C# and VB.NET. Each example consists of a report page that outputs a simple table, and the main PDF generation page. See the explanation below for further details.

    Just to note: if you are interested in further information about iTextSharp then please have a look at the collection of articles I’ve written that cover using iTextSharp for .NET PDF generation.

    (more…)

  • Today I encountered boot issues with a Samsung Galaxy S2 device. The phone has never experienced problems of this sort in the past so its refusal to start today was a surprise.

    Before I go into details about how I fixed things, I’ll give some background information on what happened.

    (more…)