Posts filed under '.Net'

Running The OUTPUT Clause From C#

SQL Server 2005 introduced a new feature called the output clause. This enables INSERT, UPDATE and DELETE queries to be run, with the original information which has been changed being returned. This is particularly useful if you want to run a query and know what has been changed by it by returning the identites of the modified rows.

The full documentation for the output clause can be found in SQL Server 2005 Books Online.

In trying to use this feature, I could get it to work in a query window, but when trying it using C# and ADO, it was not obvious how to execute the query and return the results because the ExecuteNonQuery() method of SqlCommand only returns the count of the number of rows that have been updated. After a bit of unsuccessful searching, I came across a post by Keyvan Nayyeri with something that gave me an idea:

OUTPUT clause works like a SELECT statement but its usage differs in INSERT, UPDATE and DELETE commands


Switching my code around to run the update query using the ExecuteReader() method of SqlCommand as would be used for a SELECT query proved to be fruitful, enabling the returned result set to be read.

2 comments Permalink May 1st, 2007 Adrian Banks 13181 Views
Subscribe to this feed Bookmark this post on del.icio.us Digg this post on digg.com Share this post

Windows And .Net Framework Default Versions

Aaron Stebner has compiled a list of which version of the .Net Framework is included in which version of Windows by default:

Operating System Framework Version Included As
Windows XP Home/Professional SP1 .NET Framework 1.0 + SP2 MSI Based Installer
Windows XP Home/Professional SP2 .NET Framework 1.1 + SP1 MSI Based Installer
Windows XP Media Center Edition .NET Framework 1.0 + SP2 OS Component
Windows XP Tablet PC Edition .NET Framework 1.0 + SP2 OS Component
Windows Server 2003 (all editions) .NET Framework 1.1 OS Component
Windows Server 2003 R2 .NET Framework 2.0 MSI Based Installer*
Windows Vista (all editions) .NET Framework 2.0 & 3.0 OS Component

* although it appears as an OS component, it is actually just an MSI based installer.

The MSI based installers can be used to install or uninstall the .Net Framework from the OS, enabling it to be removed completely if needed.

Very useful if you are targeting specific platforms with your .Net applications.

Add comment Permalink April 24th, 2007 Adrian Banks 8751 Views
Subscribe to this feed Bookmark this post on del.icio.us Digg this post on digg.com Share this post

AssemblyFileVersion Compiler Warning

If you are using the AssemblyFileVersion attribute to mark your compiled assemblies with specific Win32 file version numbers, you may get a compiler warning with certain revision numbers. The compiler warning looks like this:

warning CS1607: Assembly generation -- The version '2.0.0.070105' specified for the 'file version' is not in the normal 'major.minor.build.revision' format.

This warning is documented as occurring when the version string is not in the major.minor.build.revision format, but does not explain why it happens for the example above.

Frans Bouma updated his existing post with the reason why. The revision part of the version number must not exceed 65535 (ie. a 16-bit number). If it does, the compiler generates the warning. The MSBuild Team posted about the same thing, but also provided the fact that it is the underlying operating system that imposes this limit.

Add comment Permalink April 23rd, 2007 Adrian Banks 11316 Views
Subscribe to this feed Bookmark this post on del.icio.us Digg this post on digg.com Share this post

C# Data Types And Other Language Features

There's a nice little section on Microsoft's MSDN site entitled The C# Programming Language for Java Developers that explains the basics of the C# language features.

Although not incredibly detailed, it's quite a useful reference for simple language information, especially about the system types (such as the range of a double or what types can be implicitly cast to a short).

Add comment Permalink March 19th, 2007 Adrian Banks 7848 Views
Subscribe to this feed Bookmark this post on del.icio.us Digg this post on digg.com Share this post

Ambiguous Match Found

Whilst porting an ASP.Net application to the .Net 2.0 framework, I came across a spurious error when viewing a few specific pages. The error was occurring during the runtime compilation of these specific aspx pages.

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Ambiguous match found.



To make this error more confusing, the error was reported on line 1 of the aspx page which contained nothing more than the page directive tag.

After a bit of searching, I found the cause of the problem. The cause was that there were two member variables declared with names that differed only by case (one was an ASP.Net PlaceHolder control, the other an int). Simply renaming one of the variables solved the compilation error.

Eran Sandler has also encountered this problem, but delves a lot deeper into what is going on.

2 comments Permalink March 5th, 2007 Adrian Banks 11721 Views
Subscribe to this feed Bookmark this post on del.icio.us Digg this post on digg.com Share this post

Next Posts Previous Posts


Most Popular Posts



Calendar

July 2014
M T W T F S S
« Oct    
 123456
78910111213
14151617181920
21222324252627
28293031  

Posts by Month

Posts by Category

RSS Feeds Feeds

Visitors

Visitor Map

Total Hits: 757690
Hits Today: 418