Sunday, October 18, 2009

LINQ Rocks

I'm becoming a convert. The new job is awesome, I'm loving Raleigh. But this new gig has me focusing on a subset of VB.Net (ADO.Net) that I've never had to dive into before. and it rocks.

LINQ to Entities is a small but durable subset of introduced in framework 3.5. It gives you separated OOP layers to run between a DB (or multiple db's) and the rest of your framework. You can define an EDMX file to obfuscate your data, and it will generate the XML to connect your business layer to. These become your objects (entities) for the entity framework.

I've always been inherently opposed to OOP layers, they just add complexity when it isn't really needed. You end up creating spaghetti code with LINQ to Entity, but it's not as bad as it could be. and once it's built, it's built. I'm becoming a convert.

Once your data layer is built it's done. This makes the front end extraction considerably easier. You write linq queries instead of T-SQL queries, which are a completely different syntax.

The ease of front end development and flexibility of the LINQ syntax are what's really making me turn over the leaf. In T-sql, I'm hooked on aggregates. I can do anything in t-sql, been writing it for years. I'm still at the bottom of the learning curve from the LINQ syntax. But using .Include's to create joins has me intrigued. I'm actually looking forward to learning more. which hasn't happened in a long time with

Friday, October 2, 2009

Last day on the job

Well, it's good to be changing jobs. Today is my last day on this work from home job, and next wednesday I start the new gig with a software company in Raleigh, NC. The new job is all VB.Net web sites over SQL Server databases, hosted in the same environment. It's going to be nice to have something stable that isn't a pressure cooker environment where anything can be thrown at me.

Here's to new beginnings!

Wednesday, September 23, 2009

New Digs

Well, it happened. I accepted a new job offered to me yesterday. Looks like all that whining about switching to C# was unfounded. The new digs are strictly VB.Net over SQL Server. Now I have to get a car, sell the house, work my way out of this job, buy a house.... geez. let the whining begin.

Thursday, September 17, 2009

Tech support is a good thing

I've been tagging support for this one company trying to get help with connecting to an XML web service that they provide. A solid month hitting up the two contacts I got with no response, actively refusing phone calls and email responses. I eventually had to go back to my client (who chose this discount provider) and get them involved from the sales side.

It is so nice to actually get tech support from someone who know's what they are talking about. As technicians, I think we all have to strive to be that guy. The one guy who actually can provide some help even if the rest of the organization is comprised of dumbasses.

Yesterday my client went back to the salesperson, who tagged "that guy" and we had the problem fixed in 2 emails. They didn't have the numbers I was submitting in their system, the same thing I asked the other guys to check.

So go be "that guy" today. Take care of the small easy problems, and knock out as many as you can. Be helpful to our clients. They will appreciate it much more than an unreturned phone call.

Thursday, September 10, 2009


I have to profess love for ActivePDF. I think there are a bunch of PDF form filler services out there. But their ActiveToolkit software is top shelf. Today I am using it for a second process.

It's a DLL consumable with .Net, so you have to set a reference to the toolkit. But then you can open and manipulate pdf's inside of the toolkit in a bunch of ways. The first time I had to consume it was to prepopulate and/or extract data from a PDF. I got the data in an XML string, and looped through the XML nodes to shove them into the PDF. Open the input file first (source), then create the output file (destination), populate the field values in memory and call CopyForm to write the memory values to the output hard file. Very slick. I can also specify specific field names to populate, like a submit date.

Today I'm going the other direction. I am using ActivePDF to open the input (source) file, loop through each field on the PDF and inserting the field names (with some other identifying data and logging) into the database. Should be interesting and fun.

Wednesday, August 12, 2009


OK, there are DEFINITELY more jobs out there for C# guys than VB.Net junkies. A few years ago, it was the other way around. Wow, I had no idea the landscape had changed that much in the last few years. I'm certainly going to start writing more C# code.

Every job listing I see now is for a C# position, but they will take VB folks and train them, I guess. Which is really just a cruel joke. There are so many people looking for work out there, if you have the choice to hire a VB developer and teach it C#, or just hire a C# developer, which one will you choose? Got to remarket myself as a C# guy.

Friday, August 7, 2009


I started writing the .Net languages when they were initially released on valentines day in 2002. So I've been a .Net guy since day 1. Before that, I was a VB6 programmer, and wrote web sites in Notepad before moving into Homesite, then eventually Dreamweaver.

Would you believe I actually got tapped to teach a VB6 class just a couple of years ago? 2006 or 2007, I think. That old thing will never die. It's still a cool platform I guess. But I went right into VB.Net when I switched jobs and went to work for a local IT consulting firm in 2002. The first project was picking up after another programmer who initially wrote the site in C#. Then I did a small winforms program in VB.Net, then more C#, then web sites in VB. Since then, I've placed over 1,000,000 lines of VB.Net code in production, and maybe 20,000 lines of C# into production. So VB.Net has totally been my primary language for the last 7 years.

Now it seems the workforce is being dominated by C# jobs. I was talking with a trainer yesterday who had cut out all of their VB classes for lack of demand. So apparently people who want to become new or better .Net programmers want to go C#. If you do a job search for VB.Net on any of the major job boards, you find C# jobs where they will consider a VB programmer that can be retrained.

This leads me to give serious consideration to changing my primary language. I'm the only developer at the company I currently work for, so I can write any project in any language I choose. I hate a case sensitive language, and that's why I only use C# when I am forced to now. But I'm sure with time I will get used to all the nuances of the language. I recently had to translate one of my favorite scripts into C# and it was only mildly frustrating. Do you, gentle reader, have an opinion here? What do you think the programming landscape is doing?

Wednesday, August 5, 2009

DB Connection Strings

Here's how I connect to databases using

In a config file, I typically use an AppSettings value to store the setting like:

<add key="dbconn" value="Data Source=; User Id=sa;Password=; Initial Catalog=MediaDent; Persist Security Info=False" />


Provider=PervasiveOLEDB;Data Source=C:\PWorks;

SQL Server:

Data Source=; User Id=sa;Password=; Initial Catalog=dbname; Persist Security Info=False

MS Access:

Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\dbfolder\viewer.mdb; Persist Security Info=False;





And that's all I've had to connect to recently.

Wednesday, July 22, 2009

Consume .Net DLL in Classic ASP Script

I've been fighting this one all day, and I think I've finally got it figured out. I use XML web services all the time. But without a lot of crazy SOAP calls you can't use them in a Classic ASP script. My solution is to make a DLL using VB.Net that will call the web service, pass the same parameter values, and return the results back to the calling app. Seems simple, right? Here's the breakdown:

1. Create the XML Web Service. Add your exposed web methods.

2. Create a new Class Library type project. This will create the DLL. I use VS.Net 2003 and 2008 on the same dev machine. The web server I am installing this one on is running a Classic ASP web site, and IIS is configured to use the .Net framework 1.1. Also, RegAsm and GACUtil only exist on this server for v1.1, so I chose VS 2003 to build the DLL

3. Set a web reference to the web service, set the URL Behavior to Dynamic, be sure the URL is accessible from the live web server whether it be IP address or www something.

4. Use this code to build your public exposed methods:

Public Function MyMethod(ByVal psPass As String) As String
Dim sReturn As String = ""
Dim oSend As New Webservice.webserviceClass
sReturn = oSend.Method1(psPass)
Return sReturn
End Function

And repeat as needed for each web method you need to expose from the web service.

5. Right click on the DLL project, and go to Properties. This should show you the assembly property pages. On the Configuration --> Build page, check the box to Register for Com Interop. In VS 2008 it's in the project properties --> Application tab --> Assembly Information button --> check box says "Make assembly COM visible".

6. Build your DLL

7. Open the VS.Net Command Prompt that came with your version of VS. Enter the command:

sn -k "C:\myDLL.snk"

This creates what's called a strongly typed name for your assembly. You'll need that snk file later when we go to deploy.

8. Add the strong name into your DLL. Open the AssemblyInfo.vb file and add the line:

Blogger doesn't want me to display this line, so i'm going to write it out vertically.



Build your DLL again. Note the spaces in the vertical list. blogger doesn't make it very easy to post code in here that can be interepreted.

9. If VS.Net builds all of that without errors then we are ready to deploy to the web server. 2003 does not care about the config file. So minimally you will need to copy the DLL and the snk file up to the web server. My web server is Windows 2003 Server with all versions of the .Net framework installed. Everything else has to be done FROM THE SERVER CONSOLE. I put the DLL in a folder that is not behind the web server for security reasons. And I put the snk file on the root of C: just like it was on the dev workstation.

10. Open up a command prompt. Get into the C:\Windows\Microsoft.Net\v1.1.4322\ folder

11. Register the assembly using RegAsm:

regasm /tlb c:\dll\mydll.dll

This registers the dll with windows. This must be done without errors coming back before you can get any further. You must use the same version of regasm as you used to build the DLL.

12. Load the assembly into the Global Assembly Cache (GAC):

gacutil /i c:\dll\mydll.dll

If this comes back without an error you are good to go. Again, gacutil must be from the same .net version as you used to build the dll.

13. Call the DLL from the ASP Script

set oSend = createobject("MyDLL.Class1")
str = oSend.MyMethod(sPass)
set oSend = nothing

Now everything has done it's job. Your asp script called the dll, which called the web service, which did it's thing. Then (in this example) we sent a string back to the DLL, sent it back to the script and wrote it out to the browser. that's all it takes!

Bond's nerdy contra-personality

Greetings fellow nerds. I am a full time software developer, and I am starting this blog to post code and hurdles that I encounter in daily programming. I seem to find myself solving the same problems again and again. Instead of re-inventing the wheel every time, I want to create posts about solving a specific problem. Blogger lets me search through the posts so I can easily find my solutions.

Originally, I started doing the same concept on my site for a company I used to own. has a "Tips" section, where I would put up tips for each language I regularly write. there's maybe 30 tips in there, but the navigation and depth of the whole thing made it take about an hour for each tip I wanted to put up. Here, I can just copy some code, provide a brief explanation about what I am trying to do, and publish the answer. Much easier.

I am a triathlete by hobby. My training blog is at and I post funny, inspiring, and sometimes strange stories about my running, cycling, and triathlon adventures. Plus I talk about the family there, and it's supposed to be very personable. This blog, by contrast, should have no family pictures or social drive. Just the code, ma'am.

So check over to the Smoke Training blog if you want to know more about me. Comment on any of these posts if you have programming questions or get stuck with something. I'll help out when I can. I will tell you this about myself:

I am a huge James Bond fan. As much as Bond is a general badass, men love him, ladies want to be with him... I consider myself the geek equivalent. Other geeks want to write as many languages as I do. My wife wants me to step away from the laptop every now and then. If you picked up the fact that 00111 was a Bond reference, you are as big of a geek as I am. 111 is the number 7 in binary. We are going to be good friends.