I try to instal MSSQL 2008 server on Windows XP SP3.
Installation is fine but at the end it prompts an error like this.

" ' ' is not a valid login or you do not have permission. "

I use "NT Authentication\System" and I add the current user to the SQL server administrators section.

Then I read some forums and found my "user name" and "pchost name" are same. It appears like "myname\myname". It may be the issue. I created a new admin user with a different name and try to re-install the server again.

There were no errors. Finally I realize, if I try the default Administrator account to install SQL server it will not create an unnecessary account.

My opinion is :-

Remove the SQL server.

Log out from the user.

Then press two times Alt+Ctrl+Del.

Then type "administrator" as the username and press enter (If you have setup the password to the administrator account you need to give it.)

Here I'm using a library called "logging" to do the logging for me. You can statically give the log level without passing it as an argument. And also there are many log levels you can use according to your need.

Jun 18, 2011

Think that we need to go to USA, from Sri Lanka. But assume there is no direct flight to USA. So what we will do…? If there are direct flights from Sri Lanka to Singapore and from Singapore to USA, we can go to USA. In such a scenario we have two types of destinations. One is a long destination (LD) which is from Sri Lanka to USA and the other is short destinations (SD) which are Sri Lanka to Singapore and Singapore to USA. If we can achieve all the short destinations in a correct order, ultimately we can reach to our long destination. So, when we are in Sri Lanka LD is SL-USA but SD is SL-SIN. Then we travel to Singapore. In Singapore LD is SL-USA but SD is SIN-USA. Now we are in USA. Note that when we reach to Singapore we change the SD but we haven’t change the LD, because our ultimate goal is to go to USA.

Click on the image to maximize

A collection of interconnected devices are called as a network. When the number of devises gets bigger and bigger, the single network will divide into manageable sub networks. In a network all devices are recognized by its MAC (Media Access Control) address. IP address is a logical address that assigned to device in a way that human can remember, but it’s limited to a single network. The network is identified by the subnet mask. Default gateway is used as an access point to go to another network.

Think you are using the C1 Computer. You need to copy a file in S1 (4.4.4.4) server. So how C1 will communicate with S1? To do a copy you need to specify an IP address of the server. In this scenario it is 4.4.4.4. When you enter that IP address your machine will tally it with its IP address and the subnet mask. C1s subnet mask is 255.255.255.0, so its network address is 192.168.1.0. The requested IP 4.4.4.4 is not in the range of 192.168.1.0 – 192.168.1.255, or else its no in the same network. Then your computer will try to move the request to the default gateway which is specified as 192.168.1.1.

Computer will broadcast a ARP message to the network and only the corresponding interface will reply for that. Now the computer knows the MAC address of the default gateway. So it will create a packet with Source IP (S-IP) 192.168.1.1, Destination IP (D-IP) as 4.4.4.4. Source MAC address (S-MAC) is aaaa:aaaa:aaaa . But C1 doesn’t know the MAC address of the S1, and its now decided to forward the packet to the default gateway. Therefore, destination MAC address (D-MAC) will be bbbb:bbbb:bbbb.

Now the packet is in the R1 router. It will check the packets D-MAC address and feel it’s for the router R1. When it checks the D-IP address router realize that it’s not for the router but it need to go through the router to some were else. Now the router checks its routing table and realizes that the required network is not connected to it. But the router is capable of knowing neighbor route; therefore R1 will try to move the packet to the next best router. To do that R1 modify the packets S-MAC to cccc:cccc:cccc and D-MAC dddd:dddd:dddd. But it wont change the S-IP (but NAT will do a small change) and D-IP.

So this is like we travelling form SL to SIN in the example. This process will happen in all the routers which are in the path for the network 4.4.4.4.

When the packet comes to R3, it also checks the D-MAC and D-IP. When R3 checks the D-IP, it knows that it has connected to that requested network. So it moves the packet to the switch which will map D-IP to its MAC and forward it to the S1. So in this whole process MAC works as a temporary address, but IP works as the permanent address. So that’s why we need two addresses to communicate over a network.

Jun 17, 2011

We can use a syntax highlighter to display source code syntax in different colours. It will create a user friendly environment to read the source code.
I'm going to use google-code-prettify to do this task.

First thing you need to add a java script and a css to your blog. It should be placed after the <head> tag. To do this you must go to settings -> design -> edit html.
Press "Ctrl+f" and type " <head" , it will help to find the head tag. Then add the Javascripts and css like this.

Jun 16, 2011

Add 2 new Forms (Form1, Form2) to the solute on. Form1 will be the main frame and Form2 will be inside the first one. So in the first one we must make it as a MDIParent form. To do that, select the Form1 and go to its properties. In that list you will see a property called “IsMdiContainer”. Set it to TRUE. Now you will see that the form has been changed. Then go to the code behind of the Form1. In the constructor of the class, you should write this code in order to view the Form2 inside the Form1.

Note: - You can use a toolStrip instead of writing the code in the constructor.

In the previous sample code I hard code the MySQL connection string. But that is not a good practice. Because some configurations like the password will rapidly change. So if we hard code these settings, we need to compile the application each and every time after changing the password. So to avoid that overhead we use a configuration file called “App.Conf”. You can add this file to your project by going to add new item.

This is an XML file. So to add the MySQL connection string data, you need to modify this XML file into something like this.

May 28, 2011

When we are developing a web based software we must think about 2 things. One is server side and the other is client side. In the server side it will host the logic of the software and maybe the data storage. But all user interactions will be happen in the client side. If a user need to input some values, (maybe filling a form) each submit will send a http message to the server. Then according to the message it will give the response (maybe storing values in a database).

So why form validation? Forms are the main method that used to get inputs from a user. Users can input what ever he/she wants. So we can not think that a user will only fill the form according to the requirement or he/she may miss an important field. If something happens like this, it will harm the software. So to avoid such a thing we use validation.

To do the validation we get user input and check whether user inputs are according to the needs of the software. As an example, if the software need an 3 digit number, in the validation process it will check if the user had input a 3 digit number or something else. If the validation pass (user had input exactly a 3 digit number) software will continue its process(maybe storing in a database). But if the validation process fails (user had input something else), software will stop its process and it must request to re-enter the information correctly. So this request will cost some extra http requests. More http requests will cost more network usage and more network traffic. If the user enter wrong information for several times this will be worse.

To avoid this overhead we must move the validation part to the client side. From this approach we will only get valid information from the client side. So it will reduce unnecessary http requests. We can use Javascript, a client side programing language to do this.

This is a basic validation form. In this forms input field you can see something like " maxlength="5" ". It is a attribute in input tag. It can limit the number of input characters to 5. Then in the other input field (Submit button) you can see something like " onClick="return validate()" ". This is the most important part of the form. When a user click the submit button, it will trigger the "onClick" event. According to this form onClick event will call a function called " validate() ". This function will return true or false. So after user click the submit button it will be like onClick="return true" or onClick="return false". If the onClick event returns true, form will send the http request to the server. If the onClick event returns false, it will not send a http request and we can inform about the error by giving a popup like in this code.

Note:-

Although this reduce unnecessary http requests, it will add some extra code in to the html page. And also you must validate the inputs in the server side again though you validate it in the client side. There are ways to hack this client side validation process easily.

In this you can see there is a :dev-dependencies [[uk.org.alienscience/leiningen-war "0.0.1"]] and :aot [myapp.core]. First one is a plugin which can createa WAR file. The second one is to create the servlet class from the clojure file.