.NET Programmer Thoughts

Monday, March 12, 2007

I'm getting a new laptop!

It's an ASUS G1! Check out the website. I got it at www.ZipZoomFly.com. The shipping was free for 5-7 days and $5.99 for 2 day shipping!

I have not seen any bad reviews. I went to Best Buy here in Houston to check it out but it wasn't working. They were supposed to have their Geek Squad look at it but when I came back 3 hours later it still wasn't fixed. So I didn't get to see it in action.

What is so special about this laptop? It has an NVIDIA 512 video card in it! Not to mention 2GB of RAM and Intel Core 2 Duo (T7200). For UNDER $1900! It also has a 2 year global warranty!


Intel Core 2 Duo Processors T7200 2 GHz, 4MB L2 Cache, 667 MHz
Windows Vista Home Premium
Mobile Intel 945PM Express Chipset + ICH7M
2048 MG DDR2 667 Mhz RAM
15.4" WSXGA+ (1680x1050) ColorShine TFT-LCD
ASUS Splendid Video Intelligent Technology
NVIDIA GeForce Go 7700 512 MB VRAM
160 GB 5400 RPM Hard Drive
8x Super Multi DVD-RW Dual Layer LightScribe
Card Reader (MMC, SD, MS, MS-Pro)
1.3 Megapixels Video Camera
10/100/1000 Base T Lan
Integrated 802.11 a/b/g
Bluetooth V2.0+EDR
Optical Gaming Mouse
Gaming Backpack

Tuesday, March 06, 2007

Using A Timer In A Service with C#

You can't use System.Timer. It just won't work. It might look like it works at first but it just quits working.

You have to use System.Threading.Timer!

private System.Threading.Timer oTimer;

public Service1()
private void oTimer_TimerCallback(object state)


protected override void OnStart(string[] args)

protected override void OnStop()


I basically want it to fire every minute. But I stop it while I'm processing. So the second parameter on oTimer.Change() doesn't really matter.

Tuesday, February 27, 2007

MCTS/MCPD Certifications

I found a great blog that helped me understand which exams I need to take to get my MCPD's.

MCTS/MCPD Requirements Simplified

Since I have my MCSD.NET I'm going to take the following tests:

70-551 Web (DONE)
70-552 Windows
70-554 Enterpise

This will give me an MCTS in Win/Web/Ent and an MCPD in Win/Web/Ent.

New Certification

I just wanted to say something about the new certifications. THEY ARE HARD! I have my MCTS - SQL Server 2005 and MCITP - Database Administrator. I have also just received my MCTS - Web and MCPD - Web. It was an upgrade from my MCAD. I failed it the first time but managed to pass it the second time. I'm dreading taking the next two. They had added a section which is "conceptual". You may not agree with the choice but you better pick Microsoft's choice.

Thursday, June 02, 2005

New JOB!

I have a new job! I've left Software Architects and I'm now working for Travis Software as a web developer! I'm so excited about this opportunity. I have absolutely no web development experience! The other great thing is that it's about 5 miles from my house!

The technologies I will be using is XML, XSLT, and C#.

So I'm currently learning XSLT. I did some XML when I was at Traver Technologies but I used it strictly to store data in foxpro memo fields. What we are doing here is much different. And most of my original .NET studies and testing were in C#. So I'm happy to be getting away from VB.NET and back to C#!

Wednesday, April 27, 2005

Book Review: Beginning Relational Data Modeling

I’ve been a database programmer for 15 years but I’ve never kept up with the “latest” database concepts. Reading Beginning Relational Data Modeling was a great way to get myself up to date! I never learned about conceptual and logical models. So this book was a real eye-opener!

It starts out with a great introduction which includes data normalization. Every developer that works with data should know what the first three are. Apparently there has been another one added called Boyce-Codd Normal Form (BCNF). This one was new to me and I thought it was explained very well.

I thought the book was very informational. I think every developer that works with data should read this book to bring themselves up to data on the latest data modeling concepts.

Friday, April 01, 2005

Using XP Style Themes in Visual Studio 2003

Using XP Style themes in Visual Studio 2003 is easier than you might think. There are two simple steps and your forms will have an XP Style theme.

Here is a comparison of what a VS 2003 windows form looks like with and without XP Style themes.

Here is how you do it.

Step 1:

Option 1:
Create a manifest file. This file must reside with the executable file. Place the following XML in the file.

The only change you need to make is to the name attribute: Microsoft.Winweb.appname

Option 2:
Add two lines of code to the beginning of Main(). These two lines must be executed before any controls are drawn.


The DoEvents() line corrects a bug in .NET 1.1. If you don’t include it, images won’t be displayed on your buttons.

Step 2: Add some code to your windows form to change the style of the buttons. When you use themed controls, you must set the FlatStyle property to System. The system must control the entire drawing process. The FlatStyle property is used on any class that’s derived from System.Windows.Forms.ButtonBase.

When you implement these two steps, your application will emulate the theme that the operating system is using. So if you aren’t using an XP style theme, then you won’t see an XP style theme in your application. Also, you will not get XP style themes on pre-XP operating systems.

Windows Server 2003 requires another step to get XP Style themes. You have to go into services and start up a service named “Themes”. Then go into the Appearance tab of the Display properties and chose an XP Style theme.

Windows XP/2003 ships with two versions of the Common Controls library (comctl32.dll). They are referred to as version 5 and version 6. Version 5 renders controls using the standard look and feel. Version 6 renders controls with the XP look and feel. Windows Form 1.1 uses version 5 as its default library. When you include this manifest file or use EnableVisualStyles(), you are telling your application to use version 6 of the common control library.

This is something we won’t have to deal with in Windows Forms 2.0. Version 6 of the Common Control library will be the default library.

Monday, March 28, 2005

Beach Time!

I've been on the beach for about 4 weeks now. The first two weeks were great. I had so much stuff to get caught up on. Now I'm ready to get back to work!

I'm going back out to Kinder Morgan tomorrow to do a couple of days of mentoring on the system I had be working on out there. Then back to the beach. I'm also told that there is a big project starting up out there in a week or so and I will probably be on that team. It will involve converting a VB6 program to .NET. So I might get to post some interesting blogs on what I'm learning.

As for now...back to reading.

Monday, March 21, 2005

Book Review: Pro SQL Server Reporting Services

Pro SQL Server Reporting Services

I was tasked with getting up to speed as quickly as possible with SQL Server Reporting Services (SRS). I pulled out my Pro SQL Server Reporting Services book and started working through it.

Chapter 1 was on SRS Architecture. There was good information on how to install and configure SRS and it included a sample application.

Chapter 2 was on Designing Efficient Queries. Personally I just skimmed this chapter and I already know how to write queries. This came back to haunt me as I needed those queries later on.

Chapter 3 gets you started on the Report Designer. This chapter had great content. Unfortunately, there were lots of mistakes. I was actually building the reports as I worked through the chapter. It was frustrating but I figured it out.

Chapter 4 goes deeper into building Reports. It starts out with the report wizard which is a no brainer. Then it shows you how to build the reports from scratch. Good content but again, there were mistakes.

Chapter 5 shows you how to use custom .NET code with SRS. You can embed code in your reports or you can use external assemblies. There was good content here and by this time I gave up on following along with the examples. And if you download the source, there is nothing in the Chapter 5 folder.

Chapter 6 is about rendering reports from .NET application. If you want to access your reports from your application then this chapter will show you how to do it.

Chapter 7 shows you how to deploy your reports. You have to deploy them so you need to read this chapter. After this chapter, the reports I had created from Chapter 3 and Chapter 4 were now deployed to my server.

Chapter 8 discusses report management. There is really good content is this chapter. You learn about shared schedules, creating snapshots, caching, and subscriptions. Then it goes into auditing and performance analysis.

Chapter 9 is about securing reports. Personally, I think they went into too much detail to show us network monitoring. We all know that if we don’t use encryption everything will be in plain text. But they show us how to use the network monitoring utility. You have to read this chapter though get learn how to fully secure your reports so just skim the pages on network monitoring.

Chapter 10 talks about Business Intelligence and SRS. This is a good chapter if you want to see the different ways SRS can be used. It’s good stuff.

Chapter 11 tells us what changes are in store for SRS when “Yukon” comes out. SRS will be fully integrated with SQL Server 2005. You will no longer generate your report in Visual Studio. Since I’m just learning SRS, it was good to know what will be changing.

Overall the book was good. The big disappointment for me was that following the examples was so difficult. This is the first time I’ve seen this with an APRESS book.

The big question is, do I feel I’m ready to use SRS at a client site. Yes I do!

Thursday, February 17, 2005

Book Review: Pro ADO.NET with VB.NET 1.1

I had a very narrow vision of what ADO.NET was until I read Pro ADO.NET with VB.NET 1.1. ADO.NET is more than just DataSets and DataAdapters. It also involves XML, Data Services and Web Services. This book covers it all and more!

All the basics are covered. Chapters 1 through 5 explain Data Readers, DataSets (Typed and UnTyped) , Data Adapters and Data Schemas. I was impressed with the depth covered on each of these subjects.

What I didn't expect was the XML coverage. Chapter 6 covers everything you need to know about XML and how to use XML with DataSets.

Chapters 7 through 9 explain Constraints, Relations, Views, Transactions, and Mapping.

Data Services and Web Services each had full chapter. This was an unexpected bonus.

Performance and Security is covered by including optimizing, connection pooling message queuing, and basic security concerns. I always wondered what MSMQ was and now I know!

Also covered where InterOp and Migration from ADO.

The last chapter walks you through creating a MSMQ custom data provider. Very cool!

This book will make a fantastic resource book. This is definitely a must have for any level programmer!

Tuesday, February 08, 2005

More on Windows Services

I found a problem. My service was supposed to monitor an process (DBMSAutoRecover.exe) and make sure that it was always running. If it found it wasn't running, then it was supposed to start it. If it couldn't start it, then it would send an email.

Here's the problem. The process I was monitoring has a user interface. So when the service started it, you couldn't see it! So I did some searching and found out that I could go to my service (DBMSWatcher.exe) and right click on it and go to the properties window. Then on the Log On tab, check the box "Allow service to interact with desktop". When I restarted the service and the server launched DBMSAutoRecover, you could see it! But it was running under a SYSTEM account.

Now, let me complicate things even more. DBMSAutoRecover monitors another application named DBMS. DBMS is an access application that does all kinds of things. Once of which is monitor an Inbox for email. Well, if DBMSAutoRecover is running under a SYSTEM account and then has to start DBMS then DBMS is running under a SYSTEM account. When it's running as a system account, it doesn't seem to be able to connect to that Inbox.

So then I noticed that I could have the server start as a specific user. Cool! Then everything would work. But when I did that I lost the option of allowing the service to interact with the desktop. Not so cool!

So I gave up and my service will just send an email if it finds that DBMSAutoRecover isn't running.

Also I read tons of stuff about how it's not safe to allow a service to interact with the desktop. A SYSTEM account as full privileges on the machine. Then you have a user interface that has full access to the machine. No so good.

Sunday, February 06, 2005

Using a Timer In A Windows Service

I've created my first windows service in .NET! It was so easy! The hard part was getting the timer to work!

My service is named DBMSWatcher. All it does is check to make sure that a program (process) is running. If it isn't, it tries to start it and if it can't restart it, it will send an email to someone to let them know it's not running. During this time the application log is also being updated.

The first thing you have to do is create a Windows Service project. Just like you would create a windows forms project, locate the Windows Service template. It's that simple!

Most examples on the net will tell you just to add a timer control from the toolbar. Well, that isn't going to work. Using a System.Timers.Timer won't work either. At least it didn't for me. I had to use a System.Threading.Timer. Switch to the code view and you will see override methods for OnStart and OnStop.

Sorry, the code is in VB.NET again. There are lots of sources on the net to explain about to create a windows service. The key here is just to let you know the toolbar timer isn't going to work. And I couldn't get the System.Timers.Timer to work. The only way I could get a timer to work was to use the System.Threading.Timer.

Create a Private timer.

Private oTimer As System.Threading.Timer

In the OnStart method, type the following code.

Dim oCallback as New TimerCallback(AddressOf OnTimedEvent)
oTimer = New System.Threading.Timer(oCallback, Nothing, 60000, 60000)

Then create a method for the OnTimedEvent as follows.

Private Sub OnTimedEvent(ByVal state As Object)

Dim myLog As New EventLog
If Not myLog.SourceExists("DBMSWatcher") Then

myLog.CreateEventSource("DBMSWatcher", "DBMSWatcher Log")

End If
myLog.Source = "DBMSWatcher"
myLog.WriteEntry("Something Happened!", EventLogEntryType.Information)



Now look how easy it is to install the service. Go to the design windows and right click on it. Select Add Installer. It will add an installer project with two controls. ServiceProcessInstaller1 and ServiceInstaller1. Select the ServiceInstaller1 control and open the property window. Change the "ServiceName" and the "DisplayName" to what ever you want your service called. Select the ServiceProcessInstaller1 control and change the Account property to "LocalSystem".

Now build the application and create an executable.

To install the service you nned to use the InstallUtil program. You can find it in c:\windows\microsoft.net\framework\v.x.x.xxxx\. If you go to the VS .NET command prompt you will be pathed to the folder. (To get to the command prompt, select Start -> Microsoft Visual Studio .NET -> Visual Studio .NET Tools -> Visual Stuido .NET Command Prompt)

Type in the follow command in the command window.

InstallUtil "c:\program dir\DBMSWatcher.exe"

Now you need to start the service. Open the control panel and open the Administrative Tools. Click on Services, and locate your service. Right click on it and select Start to start it.

When you need to install a new version you have to stop the service and then uninstall it. Type in the following to uninstall a service.

InstallUtil /u "c:\program dir\DBMSWatcher.exe"


First you have to start your service. In the VS .NET IDE go to Debug -> Processes. Find DBMSWatcher.exe and attach the debugger. Then you will be able to set your breakpoints as usual. If you want to debug the OnStart procedure you need to place a "Stop" in the code

Wednesday, January 26, 2005

Retrieve Users From a Active Directory Security Group

Last week I was asked to add some security to the application I had written. It is basically a front-end to several access databases. It displays all the available access applications and the user can double click on one and open it. The owner of the application said users should not be able to see the whole list. Only certain users need to see certain applications.

This meant that I was going to have to maintain a user list. I really didn't want to do this. So I googled around and found that I could access the users assigned to the security group assigned to my front-end application.

The call:
Dim myADGroup As AD_Group
Dim myUserList As DataTable
myADGroup = New _Group("TrishDomain", "TrishDC", "AppsSecGroup")
myUserList = myADGroup.ReturnUsers()
Unfortunately all this work was done in VB.NET. I'm still too new at all this to do the conversion to C# for you. I also had to do some reformatting to get it into this blog so if it doesn't work just let me know and I will email you the source file.

ReturnUsers() will return a DataTable of all the users in the Active Directory Security group. The DataTable will have the user's ID and full name. DomainName is the name of the domain. ServierName is the name of a domain controller. GroupName is the name of the Security group.

Imports System.DirectoryServices

Public Class AD_Group
Private DomainNameValue As String
Private ServerNameValue As String
Private GroupNameValue As String
Public Sub New(ByVal DomainName As String, ByVal ServerName As String, ByVal GroupName As String)
DomainNameValue = DomainName
ServerNameValue = ServerName
GroupNameValue = GroupName
End Sub

Public Function ReturnUsers()

Dim strDirEntryPath As String
strDirEntryPath = "WinNT://" + DomainNameValue
+ "/" + ServerNameValue + "/" + GroupNameValue + ",group"
Dim users As Object
Dim group As New DirectoryEntry(strDirEntryPath)

users = group.Invoke("members")

Dim user1 As Object

Dim ActiveDirTable As DataTable
ActiveDirTable = New DataTable("UserList")
Dim UserID As DataColumn = New DataColumn("UserID")
Dim UserName As DataColumn = New DataColumn("UserName")
UserID.DataType = System.Type.GetType("System.String")
UserName.DataType = System.Type.GetType("System.String")

For Each user1 In CType(users, IEnumerable)

Dim userEntry As New System.DirectoryServices.DirectoryEntry(user1)
Dim fullName As String = GetUserInfo(userEntry.Name, userEntry.Password)
Dim myNewRow As DataRow
myNewRow = ActiveDirTable.NewRow()
myNewRow("UserID") = userEntry.Name
myNewRow("UserName") = fullName

Return ActiveDirTable
End Function

Public Function GetUserInfo(ByVal username As String, ByVal pwd As String) As String
Dim strRealName As String = ""
If username = "" Or username = Nothing Then
strRealName = "Invalid Signature"
pwd = Nothing ' works better if pwd is nothing
Dim domain As String = DomainNameValue
Dim path As String = "LDAP://" + domain
Dim domainAndUsername As String = domain + "\" + username
Dim entry As DirectoryEntry = New DirectoryEntry(path, domainAndUsername, pwd)
Dim Searcher As DirectorySearcher = New DirectorySearcher(entry)
Dim result As System.DirectoryServices.SearchResult
Searcher.Filter = ("(anr=" & username & ")")
result = Searcher.FindOne()
If Not IsNothing(result) Then
strRealName = result.Properties("givenName")(0).ToString() & " " & result.Properties("sn")(0).ToString()
End If
End If
Return strRealName

End Function

End Class

Sunday, January 09, 2005

Catch Up Time

It's been a while since I've blogged. I have been on assignment at "Company A". They acquired a company that had several Access databases. These databases were written by a barge Captain. So you can just image how the code looks! Everytime they tried to move the applications to another server everything would crash. So my job was to get it running in a clean environment. The other catch was that it was working against Novell's Groupwise and they want it running on Exchange. So I've been pretty busy.

There was lots of hard-coded paths and email addresses. This was the major problem. So I had to learn some VBA (Visual Basic For Applications). Then I wrote a front-end to all the databases in VB.NET. Yes, I know. I'm a sharpie. But they told me they wanted the code in VB.NET.

I dont' care what anyone says. C# and VB are not the same. The first time I got hit with "Nothing", it took me about two hours to figure it out. There doesn't seem to be "Null" in VB. It's "Nothing". The other big thing is that the properties windows doesn't show you the list of events for the control. Which means you can't double click on the event and have it write the code structure for you. Which also means that you have to remember what events are available and what their signatures are.

So I can say now that I've written my first .NET application. I'm told I will have a code review next week. SARK sends me out to a site all by myself, with no .NET experience, and then wants to do a code review. Well, it's good code. Bring it on!

Sunday, December 12, 2004

Beginning C# Databases: From Novice to Professional

If you are new to working with database servers, Beginning C# Databases is a great place to start. It begins by showing you how to install MSDE and takes you all the way through developing windows and web applications that access the Northwind database. There is a lot of code in the book but when you’re beginning, you need to look at code. The full source is listed and then it takes you step by step to show you what it’s doing.

Definitely download the code samples. There are a couple of great tools. If you don’t have access to SQL Enterprise Manager, you will find them very useful!

The book flows from topic to topic very smoothly and stays on the subject. It is such an easy read. It will definitely stay in my library as a reference on SQL Server.

Friday, December 10, 2004

DAAB - Data Access Application Block

Have you ever used the DAAB 3.1? Well, I've been trying to. Good luck trying to find documentation. I can get it to work for some things and other things just won't work.

If anyone knows of any good documentation please post the link.