Geeks With Blogs
Eron Wright - All Killer No Filler blog Technology
Working with Query Analyzer and FOR XML

If you work with SQL Server 2000 and FOR XML functionality, you curse Query Analyzer probably as often as I do.  Here are some tips for improving the output:

  1. In QA, set “Maximum Characters per Column” setting to 2033
  2. Execute DBCC TRACEON(257) to pretty-print the XML output

http://www.winnetmag.com/SQLServer/Article/ArticleID/20698/20698.html

Posted On Wednesday, September 15, 2004 2:40 PM

UTC datetime values in SQL Server 2000
You can convert local datetime values to UTC datetime values, and vice-versa, using the built-in GETUTCDATE() function: DECLARE @LocalDate DATETIMESET @LocalDate = GETDATE() -- convert local date to utc dateDECLARE @UTCDate DATETIMESET @UTCDate = DATEADD(Hour, DATEDIFF(Hour, GETUTCDATE(), GETDATE()), @LocalDate) -- convert utc date to local dateDECLARE @LocalDate2 DATETIMESET @LocalDate2 = DATEADD(Hour, DATEDIFF(Hour, GETDATE(), GETUTCDATE()), @UTCDate) SELECT @LocalDate, @UTCDate, @LocalDate2 Note ......

Posted On Tuesday, September 14, 2004 11:35 PM

Use C# comment styles to your advantage
Comments within a C# method body tend to A) make a problem statement then B) document the steps to solve the problem. The problem statements tend to be multi-line; the details of the solution tend to be single-line. I want the problem statements to stand out. Traditionally I use #region blocks to group the problems. Unfortunately, regions are single-line. They are also slightly more laborous to construct. Lately I have been using a triple-slash comment block at the top of the method body to state ......

Posted On Thursday, May 27, 2004 6:46 AM

HTTP GET Idempotence and ASP.NET
I am struck by the consequences of the experience Craig relates in this post: http://staff.develop.com/ca... He is discussing a Wiki site that mysteriously had its page content rolled back to a previous version. Wiki pages generally contain a link to do this, and it is assumed that a human would follow it with caution. Turns out that GoogleBot crawled the site and what-do-you-know the content rolled back. The underlying problem ......

Posted On Wednesday, May 26, 2004 12:40 PM

C#: Properties versus getter methods
You might be wondering why some classes in the .NET Framework have properties, other classes have GetXXX methods, and some have a combination of the two. The reason is that the semantic, or meaning, is quite different. Consider this class: public class Customer{ public int CustomerID; public string FirstName; public string LastName; public Order[] GetOrders() { // do database work }} The CustomerID, FirstName, and LastName represent the customer state. The orders are derived from the customer state ......

Posted On Sunday, May 2, 2004 8:18 AM

C#: try..catch Usage
When catching an exception in C# you need not declare a variable for the exception instance if you do not need it. This will avoid the “unused variable” warning. try { /* ... */ } catch(Exception) // catches without assigning to a variable { // ... } Here is how to rethrow an exception without affecting the stack trace: try { /* ... */ } catch(System.Data.SqlClient... ex) { if(ex.Number==2627) { /* special case for primary key violation */ } else throw; // rethrows without affecting ......

Posted On Friday, April 16, 2004 9:41 AM

Shell Extensions with .NET
Edamno has released a VB.NET library for creating various shell extensions Browser Helper Objects Context Menu Handlers IE Menu Buttons InfoTips Property Sheets Thumbnails http://www.mvps.org/emorcil... He also has a library for working with Windows Task Scheduler, and, most importantly, a library for working with OLE Structured Storage. Now you can read and write the author and comments associated with a file ......

Posted On Saturday, April 10, 2004 8:52 AM

Matching Parenthesis Pairs Using Regular Expressions
It is a known hard problem to match nested parenthesis pairs using regular expressions. Put another way, regular expressions to not typically support counting occurrences. .NET has a little-known RegEx construct for doing just that called the “balancing group definition“: Balancing group definition. Deletes the definition of the previously defined group name2 and stores in group name1 the interval between the previously defined name2 group and the current group. If no group name2 is defined, ......

Posted On Monday, March 29, 2004 12:01 PM

ASP.NET - files handles are kept open for each directory in Request.PhysicalPath
If you are using IHttpHandlers to serve dynamic content, or generating a large directory structure to be served statically, here is some information you should know. We use a custom IHttpHandler to dynamically serve (and cache) images from our database. For simplicity, the handler uses Request.PhysicalPath as the ultimate cache location. That is, a url “~/cache/123/1-Large.... is mapped to “<path to application root>\cache\123\1-Large.... by the handler. If the file ......

Posted On Tuesday, March 2, 2004 4:42 AM

Indigo - use of HttpContext.Current.Server.MapPath
I have heard Don Box speak about the caviats of using the Indigo service model. He states that service classes should not use transport-specific API - notably the use of HttpContext. The logic is obvious. The problem is that my ASMX web services must often use XSD files that are in the same directory as the ASMX file. HttpContext.Current.Server.... is used to resolve to a local path. What is the recommended API for doing such resolution without HttpContext? Don, your comments would be appreciated ......

Posted On Sunday, February 29, 2004 6:00 AM

Copyright © Eron Wright | Powered by: GeeksWithBlogs.net