Erik Porter's Blog

Life and Development at Microsoft and Other Technology Discussions

News

    November 2005 - Posts

    Upgrade Password Hashing From .NET 1.1 to .NET 2.0
    If you're having troubles upgrading your ASP.NET 1.1 app to 2.0 because of hashing your passwords "not working", my long time friend, Joe, figured it out.
    Posted: Nov 29 2005, 03:07 PM by HumanCompiler | with 4 comment(s)
    Filed under: ,
    Taking Advantage of Xml Data Type in Sql Server 2005

    There are a ton of interesting things you can do with the new Xml data type in Sql Server 2005.  The first quick thing that came to mind was to pass in an Xml document into a stored procedure to have many rows deleted at one time in a batch without having to use a loop with a transaction outside of Sql Server in .NET code.  This could be done before in Sql Server 2000 by passing in an Xml document as a nvarchar then using OPENXML to parse out the values you need.  I find the new way to be a bit cleaner.  Here's a little t-sql script you could easily turn into a stored procedure to do multiple deletes at once.

    DECLARE @IDList xml

    SET @IDList = '<IDList><Item ID="1" /><Item ID="2" /><Item ID="3" /></IDList>'

    DELETE FROM
        
    MyTable
    WHERE
        
    MyTableID IN
        
    (
             
    SELECT
                  
    IDList.Item.value('@ID', 'int') AS ID
             
    FROM
                  
    @IDList.nodes('/IDList/Item') IDList (Item)
        
    )

    In short, it's just saying, give me the nodes that match this XQuery, then gives the results an alias of IDList, saying that it has one field in it called Item and then calling the value method on it asking for the attribute called ID and making sure it's returned as an int.  It then returns that result to the calling delete statement so any row with those IDs in your table will be deleted.  Pretty simple and neat, but the xml data type starts to get really neat when you start storing metadata about each row.  You can use the documented methods to pull out different fields in your result set from the xml field in your table so they act just like any other field inside of Sql Server.

    I am by no means an expert at Sql Server 2005 so if there's a better way to do what I've demonstrated, please post a comment.  The documentation seems to be a big lacking right now.

    ASP.NET MembershipUser ID Field

    I'm currently playing around with the new membership stuff in ASP.NET 2.0.  It is simply phenominal.  I love it.  It was a little hard to figure out at first, but once you get going it's really powerful and great.  I'll probably post some more "basics" on it down the road.

    When creating tables of your own to integrate with the aspnet_Users table like adding UserID to your own table that is an FK back to that table, you'll need the ID field (UserId in the aspnet_Users table) to pass into your Stored Procedures.  Unfortunately, it's not very obvious where it comes from, but if you grab an instance of the current MembershipUser (one way would be to use Membership.GetUser(User.Identity.Name)), there is a property called ProviderUserKey.  This is the ID field in sql (if that's the provider you're using) and is a Guid.  You'll have to cast it because the property itself is of type Object (because whatever provider you're using could return a uniqueidentifier, int, etc).  Hope this helps someone find it faster than I did.  ;)

    Posted: Nov 27 2005, 04:21 PM by HumanCompiler | with 8 comment(s)
    Filed under:
    Beck - Hell Yes Video Featuring Sony QRIO

    Boing Boing points out the new Beck video uses robots for the dances.  Very cool and good song too!  :)

    I believe they're doing the dance that's on this video.

    Go check it out!

    Now, when am I going to be able to use .NET to access higher functions to tell one of them to go get me another Mountain Dew?  :P

    Posted: Nov 19 2005, 03:36 PM by HumanCompiler | with no comments
    Filed under:
    GotDotNet Birthday Party

    The Gotdotnet team is throwing a Birthday Party and all Gotdotnet users are invited! The party will occur at the Microsoft Visitor Center this Friday, November 18, 2005 between 6PM and 10PM. For more event details, see http://blogs.msdn.com/korbyp/archive/2005/11/14/492390.aspx or visit the Gotdotnet homepage.

    Posted: Nov 14 2005, 06:39 PM by HumanCompiler | with no comments
    Filed under:
    New Atlas Build
    http://weblogs.asp.net/atlas/archive/2005/11/07/429861.aspx
    Hot Topic (New Yahoo Maps and Google and Microsoft)
    Interesting post by Scoble.  Check out the comments.  Lots of interesting things going on in there...
    Posted: Nov 03 2005, 12:07 PM by HumanCompiler | with no comments
    Filed under:
    New Microsoft Gadgets Site

    http://www.microsoftgadgets.com

    They've added a gallery for gadgets and forums.  Looking good!

    More Posts