Tuesday, September 10, 2013

Extension Method for DB Reader

I was doing some quick and dirty data access for a demo program the other day. I was annoyed by having to call reader.IsDbNull() every time a DB field was a nullable simple type. My buddy Milenko and I created the following to make things look a little neater:

public static class ExtensionMethods
{
    public static T? GetNullableValue(this IDataRecord reader, string fieldName) where  T: struct
    {
        int ordinal = reader.GetOrdinal(fieldName);
        if (reader.IsDBNull(ordinal))
        {
             return null;
        }
        return (T)reader.GetValue(ordinal);
    }
}

Friday, March 29, 2013

Node.js on Windows Azure - Issue With WebMatrix

I am going through some of the node.js material on Pluralsight. I am currently working on the Node in Windows and Azure modules.

I'm pretty sure that I went through the steps as described in the vids for getting WebMatrix working for an Azure website. I was able to create and publish a working node.js website to Azure, but I couldn't get it run locally (the browser showed a 500 error). I tried running the Etw.bat file that comes with iisnode, and I saw the following:

First, a whole bunch of events that said iisnode scheduled a retry of a named pipe connection to the node.exe process", followed by the event iisnode was unable to establish named pipe connection to the node.exe process. Finally, I saw iisnode request processing failed for reasons unrecognized by iisnode.

The page that showed the 500 error recommended that I make sure that the app pool user had permissions to the folders where the website was, C:\Users\Steve.Harclerode\Documents\My Web Sites. So I made sure that IIS APPPOOL\DefaultAppPool had full permissions, but I saw the same error. I even tried giving full permissions to Everyone for the folder, but that also failed.

I copied the app to a folder under a currently running iisnode application, and I was able to run it from there just by browsing to it from IIS. Unfortunately, that folder is under C:\Program Files, and I couldn't save files there unless I logged in as admin

What finally worked was to choose Add Application under IIS and select the original folder. Honestly, I'm not sure why this worked, since WebMatrix runs the program using another port, in my case 34581. I'm hoping wiser minds than mine will comment on this blog. :-)

Friday, March 22, 2013

BizTalk is Alive!

I have heard (or read) several people claiming that "BizTalk is dead." Microsoft seems to disagree though, they just released BizTalk 2013 to MSDN. I hear through the grapevine that it will be generally available April 1.

Wednesday, March 20, 2013

SharePoint 2013 Configuration Error

I don't normally just post links, but this one saved my butt for a single server installation of SharePoint 2013. The error message I saw was "The SDDL string contains an invalid sid or a sid that cannot be translated.". I saw the error while I was running the configuration wizard.

Monday, April 02, 2012

Neuron ESB

Lately I've been learning how to use an ESB that my company (Neudesic) created. I'm really liking it, it seems very intuitive and easy to use. It has a bit of overlap with BizTalk functionality, but I think that both of them together make a great team. I'm not very fond of the BizTalk ESB Toolkit, so I'm glad to find something I like better.

The product is called Neuron ESB. I don't have time to go into detail at the moment (deadlines, you know!), but I plan to write more later. You can click on the link for more details.

Tuesday, March 06, 2012

SQL - Split Using Common Table Expression

In working with SQL server, I have often needed to use a Split function, which will take a string and a delimiter, and return a table of tokens from the string. The only problem is that my clients have not always been happy about needing to add a function to the DB.

I have recently discovered Common Table Expressions (CTEs), thanks to the San Diego Tech Immersion Group. I found a CTE that I was able to modify to produce the table of tokens from a string, just like the function above. Here's my modified query with a test string:
DECLARE @str AS NVARCHAR(MAX)
DECLARE @separator AS NVARCHAR(2)

SET @str = 'test1
test2
test3
test4'
SET @separator = CHAR(13) + CHAR(10)

;
WITH Split_CTE(rowNum, stringStart, stringEnd) AS
(
SELECT
1 AS rowNum,
CAST(1 AS BIGINT) AS stringStart,
CHARINDEX(@separator, @str) AS stringEnd
UNION ALL
SELECT
rowNum + 1 AS rowNum,
stringEnd + LEN(@separator) AS stringStart,
CHARINDEX(@separator, @str, stringEnd + 1) AS stringEnd
FROM Split_CTE
WHERE stringEnd > 0
)
SELECT
rowNum,
SUBSTRING(@str, stringStart,
CASE WHEN stringEnd > 0 THEN stringEnd - stringStart ELSE 2000000000 END) AS StringValue
FROM Split_CTE
;
I've tested this extensively for almost 2 minutes!

But seriously, if it fails when testing the application I'm working on now, I'll modify this post.

Wednesday, August 10, 2011

Message - "The MSDTC transaction manager was unable to push the transaction..."

A client recently saw a strange error after installing a new BizTalk 2010 application. The app produced the following error when using the WCF SQL adapter to connect to a remote SQL database:

The adapter failed to transmit message going to send port "RequestMessageData" with URL "mssql://VSQL05.PROD.acme.com//Messages?". It will be retransmitted after the retry interval specified for this Send Port. Details:"System.Transactions.TransactionManagerCommunicationException: Communication with the underlying transaction manager has failed. ---> System.Runtime.InteropServices.COMException: The MSDTC transaction manager was unable to push the transaction to the destination transaction manager due to communication problems. Possible causes are: a firewall is present and it doesn't have an exception for the MSDTC process, the two machines cannot find each other by their NetBIOS names, or the support for network transactions is not enabled for one of the two transaction managers. (Exception from HRESULT: 0x8004D02A)

At first I thought the error might have to do with the fact that the SQL address is virtual. But after some flopping about like a fish on deck, we found a guy at the client site who knew MSDTC really well. He suggested that we choose the "Enable XA Transactions" option in the DTC properties dialog box. I didn't know it at the time, but the production DB was in SQL 2000, running on an older version of Windows. The QA DB had been SQL 2005.

That fix didn't work by itself (there was another issue), and then I remembered that I once ran into something like this when installing BizTalk 2004 for another client. In that case, I had to select "No Authentication Required" in the MSDTC properties on all boxes. But since I knew that no request was going to be coming from SQL 2000, I selected "Incoming Caller Authentication Required". Problem solved!