Mostrar / Ocultar Avisos

Archive for ‘.Net / C#’

Simple Syntax for XML node looping

Sometimes I really hate .Net blogs and C# websites.

All I wanted was the syntax to loop through the nodes of an XML document. You’d think that would be easy to find.

WRONG!

My search lead me to many long winded dissertations on to use XML for web services or someone’s home grown SAX implementation but no simple syntax that wasn’t buried in 1000 lines of code. Seriously, who is going to read 1000 lines of code in a blog post?

Anyway, I’ve distilled it below. I know it’s simple. But, I couldn’t find simple. Maybe my google skillz are lacking.

This code assumes you have “customer” nodes within your XML document and each customer has an attribute called “name”.

I realize the above code reassigns nodeValue each time through the loop, but I just wanted to show the syntax for retrieving an attribute value.

ASP.Net 2.0 and It’s Crazy Strict Install Order OR Be Careful When Installing Windows Components

Recently, I re-imaged my work machine and had to re-install all of my development tools. See here for a list. The one thing I did pay attention to was to make sure IIS was installed before Visual Studio and ASP.Net 2.0. If you do it backward you’re in for a fun filled day of error messages leading your nowhere. But, I did it right so I didn’t have to worry.

Then this morning everything went to hell and the very descriptive errors appeared and I spent a few hours googling and trying some of the Kbases at Microsoft. Nothing worked until I tried this which states the cause as…

The most probable cause for this error is that you must have installed Internet Information Services (IIS) after the installation of Microsoft .NET Framework 2.0.

But remember I did do it in the right order. Right? To make a long boring story short I was messing around with adding and removing some Windows Components from the Add/Remove Programs wizard and sowhere along the line it must have reinstalled part of IIS. Either that or the Network Gnomes are back.

How to Return a Generic .Net DataSet from the OpenEdge AppServer

Recently at work we needed a good, and easy, way to get data stored in our massive ERP system running an OpenEdge database to some of our .Net apps. At first, we just had ASP.Net connect directly to the database through ODBC which was good enough for our prototype. However, if we were to continue using this method it would require our Microsoft developers to learn a totally new and convoluted schema. Plus, they would have to use embedded SQL statements like…

** dbBroker and GetDataTableBySQL are part of our in-house framework but you can get the idea.

Embedded SQL is a code maintenance nightmare in my opinion. I’ve never liked mixing languages like this. Fortunately, OpenEdge comes with a better way call the Open Client Toolkit (sorry, no link). To quote the product literature the Open Client Toolkit is used “to generate .NET, Java, and Web services proxies for accessing business logic.” In our case we used it to create DLLs which we can reference in our Visual Studio projects.

[I will post another article on the specifics of using ProxyGen from the Open Client Toolkit to create .Net DLLs]

This process works much better as our MS developers can just make a call to the methods in the DLLs (I’ll write about this is another article) and not have to worry about the ERP’s crazy schema while our Progress developers can actually create real business logic procedures to aggregate data. The only problem with this scenario is that every time we want to add to the AppServer code we must regenerate the DLLs and make the .Net apps reference them properly. Talk about a pain in the ass.

Here is how we I solved this problem. Read the rest of this entry »