Application Setting in VB and C#

Application setting can be user-scoped or application-scoped. The user scoped one can be read and write at runtime.For example, assign value Variabl1 to a user-scoped application setting will be like the following





The user.config file will be stored against the logged in user,

Windows XP:
C:\Documents and Settings\username\Local Settings\Application Data\companyname\Applicationname\application.exe$%^&*


Web Service, the beginning

Web service in consists of a file with the .asmx extension, so you’ll have something like this
<%@ WebService language="VB" codebehind="Service1.asmx.vb" class="Service1" %>
Imports System.Web.Services
Public Class Service1
Inherits System.Web.Services.WebService
Public Function HelloWorld(Byval name As String) As String
Return "Hello World " + name
End Function
End Class

To test this, browser http://localhost/WebService1/Service1.asmx and a simple interface with a list of methods show up.

Click on any one, and put in values for all parameters, click ‘Invoke’ to see the result, it’s not as hard as I thought it would be…

Howto: send e-mail from SQL Server 2005 – sp_send_dbmail

Problem: I need a stored procedure that checks bugs in the support system and find out if any of them have not been responded or completed in the scheduled time and send out emails to different people according to how urgent they are. The stored procedure is fairly easy to write except to work out the working days. Anyway, the focus here is how to send email from SQL Server.

Solution: The stored procedure xp_sendmail is not recommended to use in 2005, so now we use sp_send_dbmail. First, we need to enable database mail. Right-click on Management node and select Configure Database Mail option, you will be prompted to enable this option if it was not enabled, and setup through the wizard.

Continue reading

Howto: simply concatenate multiple rows of data into a variable in SQL Server 2005

Problem: I have a select statement that returns more than one rows of result, and I need to concatenate all rows into one. For example, if I have a table called ‘Game’ and it returns the following result when you select all and you just want to get a list of games’ names:

gameId Name
1 Rayman: Raving Rabbids
2 Naruto: Rise of a Ninja
3 Guitar Hero III: Legends of Rock
4 Dynasty Warriors 6

Solution: usually I would thought of to loop through it or in more complex cases, to use a cursor. However, I found a really easy way today (you don’t need to declare the variable asNVARCHAR(MAX), just in case if you have heaps of games and happen to use SQL Server 2005 or above).

SELECT @games=@games + Name +', ' AS GameList FROM Games
SELECT @games


Rayman: Raving Rabbids, Naruto: Rise of a Ninja,Guitar Hero III: Legends of Rock,Dynasty Warriors 6,…

Of course you’ll need to get rid of the last ‘,’ from the variable at the end. How simple, and how could I never knew this before!

DateTime.Now vs. DateTime.UtcNow

I was modifying customer support site today, and one of the change is to have NZ time displayed with sun/moon image. This may seem to be a useless thing to do since anyone has the browser would have the time showing on the right bottom corner of their screen (or right top if using mac). But if you have SMS linked to support site, you definitely don’t want to receive message in the middle of the night.

Anyway, I never realize there’s a UtcNow function, basically it’s the standard international time that all time zones are expressed as offsets of, it’s not offset to daylight saving. There’s also a getutcdate() in SQL Server verses getdate()

world time zone

Howto: Install Zimbra on Ubuntu 6.06 LTS

I’m absolutely new to Zimbra, so the installation didn’t went well for the first time, especially when everything needs to be done on terminal, but overall it’s not that hard to setup and the ajax interface looks really cool.

missing modules on Ubuntu, when I try to install, the following message show up
sudo...FOUND sudo-1.6.8p12-1ubuntu6
libstdc++6...FOUND libstdc++6-4.0.3-1ubuntu5

I added all except fetchmail back by using apt-get install from the terminal:
sudo apt-get install libidn11 libpcre3 libgmp3c2 libexpat1 libxml2 libstdc++5 openssl libltdl3
Continue reading

Daylight saving delayed for two weeks in NZ

I went to work today at 9:30, and when I log in to my computer, I saw the clock says 8:30, so I thought that must be the daylight saving ended (I never know when this happens every year -_-#), so I turned to my colleague and asked a seemingly stupid question – what time is it now. He confirmed it’s 9:30. So I changed my time on the computer (and didn’t realize the change is not saved), and later on around 11:50 I wanted to make a phone call, I checked my mobile phone and it confirmed the time. I called, and turns out it’s 12:50. Shocking… I use iPhone, and it’s not sync with my workstation but only to the iMac at home, how could these two not related, individual things changed time at the same time, something …

I’m all puzzled and told another colleague, and found out that because the daylight saving has been delayed this year (I knew this actually), but my computer does not know that. What? Why? We’re all in the same network and all computer and servers should be updated at the same time. Turns out our administrator didn’t apply the patch and other people from my team already have that updated (my computer used to be on a different domain because I worked for a different team)

Anyway, that’s just a story, to correct this error, don’t change your time manually, choose and download an update from Microsoft and it’ll all be fine.

Yes, I use this clock at home and it’s really hard to read…