Tuesday, November 29, 2005

Google Reader

Google came up with new tool called Google Reader. It is a web base RSS feed reader. You need to have GMail account in order to use it. I used to bookmark all my fav. blog links in browser and there is no way to browse them using another machine. With Google Reader, now I can read those blog from anywhere. I think it is better than using any desktop RSS reader application. PS: Like other google tools, Google Reader is also very fast and also make use of AJAX technology.

Friday, October 07, 2005

Insert and Delete with DLinq

In my last entry, I showed how to fetched record from SQL server using LINQ. I did some more work on LINQ and was able to insert a new record and delete particular record using LINQ. In order to insert or delete, I needed to start Distributed Transaction Coordinator in my SQL server. Below is the simple code use to insert a record,
Authors aut = new Authors();

aut.AuId = id;
aut.AuFname = fName;
aut.AuLname = lName;
aut.Phone = phone;

db.Authors.Add(aut);
db.SubmitChanges();
Continuing the work I left last time, I made an object of Authors and added ID, first name, last name and phone to it. Then calling the SubmitChanges method, the actual data is written to database. Similarly, deleting a record is also not so hard.
var authors = (
    from a in db.Authors
    where a.AuId == id
    orderby a.AuFname
    select a).First();

db.Authors.Remove(authors);
db.SubmitChanges();

In order to delete a record, First method is called with the query, which returns a particular record. By passing this record to the Remove method of Authors object, a record will be deleted. With this, record deletion is only limited to memory data. Actual record will be deleted only after calling SubmitChanges method. The next step is to explore transaction in LINQ.

Linq and DLinq in action

Beta version of Visual C# 2005 Express Edition was lying around my hard disk for some times. I was stuck with a project and didn't have chance to look into it. When I visited LINQ site, I found the way to use it. I've downloaded Tech Preview version of LINQ and installed it. Integration with Visual C# 2005 was not so hard and I was already in new Linq consol application window. I found couple of doc files on 'Hands on Lab' inside 'Docs' folder. After reading a file for DLinq, I got general idea on how actually LINQ works. In order to start with DLinq, I first made a ObjectModel of 'Pubs' database using a tool 'sqlmetal.exe'. This tool is installed in Bin folder and able to create a C# source file which contains mapping of every table and column to respective objects. The resulting source was then included in Linq console application. With little modification in ObjectModel, I was able to use SqlConnection object with my 'pubs' class. By writing a code (as shown below), I was able to see the result of database immediately. The bottom line is, with LINQ, there is no need to write SQL. The query language is now integrated in programming language. I think it is easy to use and developer doesn't need to have knowledge of SQL. Till now, I have learnt to get the result from database. Now my target is to learn how to insert, update and delete records using LINQ.

using System;
using System.Collections .Generic;
using System.Text;
using System.Query;
using System.Xml.XLinq;
using System.Data.DLinq;
using System.Data.SqlClient;
using pubs;

namespace LINQApp
{
    class Program
    {
        static void Main(string[] args)
        {
            dbQuery();
        }

        static void dbQuery()
        {
            SqlConnection conn = 
                     new SqlConnection(@"SERVER={YourDBServer};user id={uid};password=;database=pubs;");
           
            Pubs db = new Pubs(conn);

             var authors = 
                 from  a in db.Authors
                 select a;

            foreach (var auth in authors)
            {
                Console.WriteLine(" {0} {1} | {2} | {3} ", 
                                       auth.AuFname, auth.AuLname, auth.Address, auth.Phone);
            }
           
            Console.ReadLine();
        }
    }
}

Wednesday, September 21, 2005

The LINQ project

This is really interesting. Microsoft has came up with the new project called LINQ (Language Integrated Query). By extending C# and VB.NET language, it provides few classes to take advantage of the database query. The real version of LINQ is targeted for C# 3.0 and is in preview state now. The downloadable tech preview version only works with VS.NET 2005 beta or Visual C# 2005 Express Edition Beta 2. Still, there are 2 more flavours of LINQ, XLinq and DLinq. Former is for using XML as a database, while latter is use for relational database. Currently, DLinq only supports MS SQL Server (no surprise) :-). I've downloaded and installed LINQ tech preview and it is working fine with my copy of Visual C# 2005 Express Edition(beta). I will be exploring it in depth in coming days. BTW, Channel 9 video in which Anders Hejlsberg explains the features of LINQ is worth watching.

Thursday, September 15, 2005

Camera, Action, Go!


Well, my new camera is already in action. Here is a sample. This picture was taken at 6 this morning at my house terrace.

There are few more to watch on flickr.

Wednesday, September 14, 2005

Learning Photography

I don't have any hobbies except music and reading computer related stuffs. I was thinking about doing some photography but that never happen. Taking good pictures and showing them to friends was what I thought about. it's now time to learn some photography as I have upgraded my camera. I had Nikon Coolpix 2000, which is point-n-shoot kind of camera. There is nothing much to think about while taking a shot. Recently I bought Olympus C-765 Ultra Zoom. I couldn't believe that it has so many features. Even after going through it's online manual , I couldn't understand the functionality. Because I don't understand buzz words from photography world. I am very thankful to my friend Om, who explained some of the features in detail. I am now in position to get some nice shots of objects around me. In order to understand the concept of Aperture, ISO, Depth of Field etc, I tried to search the Net for resources. Among many web sites, I found Photoxels site very useful. Everything in this site is very clearly explained. After getting used to the camera, I will be uploading pics to flickr.

Tuesday, August 23, 2005

New Job

For some good reasons, I quit my old job and joined new office. I will be working as .NET programmer here. Very few companies use Delphi in Nepal, and this one is also not an exception. I am pretty sure that I will be using C# as primary language. But I won't miss a chance of making use of Delphi . As I've already started working, I was assigned to ASP.NET project. I always prefer web programming in .NET, rather than Winform application development. It is not that I am refusing to work in Winform application, but .NET is more fun with ASP.NET.

Wednesday, August 03, 2005

Reporting with RAVE

If you don't know what is RAVE, it is a default reporting tool for Delphi. Delphi used to have Quick Report but Borland choose RAVE as default reporting tool. The main reason for choosing it over other is, it is written using cross platform components (CLX). Also, RAVE offer some good features like mirroring, global page, etc. I am currently working on a medium size project in Delphi and I need to build couple of reports for it. I have never used RAVE before but read and heard lot about it. I decided to give it a try. After reading some tutorials in BDN site, I started working on it. With my previous experience with Crystal Report, I found that RAVE handles reporting completely different way. Designer is easy to use and concept of generating report is cool. One can create report and save it as external file. Also, it can be embedded into application. Even further, report can be saved and extracted from database. Cool, isn't it? From my experience, I think learning RAVE is little difficult, but once you know how to do things, you have total control of report. What I miss about this great tool is, documentation. Every piece of software needs good documentation and RAVE is not an exception. If it offers so many nice things, they must be documented. With RAVE Scripting, I am still lost. Although there is a news group for supporting RAVE user, I didn't find it quite helpful.

Wednesday, July 13, 2005

The 24 hours of Delphi

I've been listening to '24 hours of Delphi' in BDN radio. It's already in 7th session and Deepak Shenoy is speaking now. I won't be able to listen to this live event till tomorrow morning because it is already 5:30 PM in Nepal and it's time to go home. I will definitly continue listening it after coming to office tomorrow morning.

Friday, June 17, 2005

Namespace in Delphi


I must say that namespace support in Delphi is very strange. While disassembling Delphi produced assembly with Lutz Roeder's .NET Reflector, the result was surprising. At the same time, result of C# produced assembly was fine.

Also, I am really impressed with the namespace support in Chrome.

Thursday, May 26, 2005

Experiencing 'Chrome'!

If you know (Object) Pascal very well and you want to do some .NET programming using VS.NET, you must try RemObjects Chrome. I am currently evaluating Chrome with VS.NET 2003 and I find it very interesting. It introduced some new keywords and some new language features. Being a Delphi developer, I didn't have any problem creating sample application in Chrome. I tested with very small Chrome Class Library and Chrome Windows Application. It was really nice to see that I can have C# project and Chrome projects in single VS.NET solution. Also, everything worked perfectly when using Chrome made Assembly in C# Windows Application. I will be testing Chrome with more ASP.NET as I am really not interested in WinForm application. Not to forget that Chrome also supports Mono platform. In my opinion, this is another best thing after Delphi 2005.

Tuesday, May 24, 2005

I won a book!!

I am one of the winners of April 2005 books contest held by PCQuest magazine. I got Wireless Web Development with PHP and WAP book as a prize. Isn't it GREAT?

Monday, May 16, 2005

Summer is here


Yes, it's summer time. We use to hang out at near by club each Saturday. After a week long work, this is probably the best way to relax.

Tuesday, April 19, 2005

New Year and my honeymoon

Last week was our (Nepali) New Year. It's 2062 in Nepal. See we were in 2000 long ago. ;-) After spoiling my honeymoon first time, I planned for it again. Pokhara was our destination and the day was 1st of Baishak(14th April 2005, Nepali New Year day). We reached to airport in time. While recieving our boarding pass, the clerk said that airport in Pokhara has been shut down because of bad weather. We didn't have choice and waited for airport to open. After waiting for 4 hours, our flight was cancelled. DAMN! I don't know what is wrong with my luck? This is the second time! :-( Me and my wife return to home with sad mood. I didn't want to spoil my holiday this time. So, we decided to go to Nagarkot and called for booking. Luckily we got reservation and went there and had really GREAT time. :-)

Friday, April 01, 2005

Bye Bye 'VB'

Although VB guys are asking for Microsoft to support VB6, I am sure that this is not going to happen. The problem is that, VB guys don't know and can't do OOP, that's why they are asking for VB6. I personally define VB as power tool, not RAD, not programming tool. Based on Microsoft's flop technology, ActiveX, it is just a tool to create windows application faster. Anyone can make windows application without any programming background. And I think most of the VB guys fall in this category. I don't even like to call those people 'developer'. The question is 'Why those people are asking for VB6 support?', 'Why don't they just go ahead and learn VB.NET'? The answer is simple. They just can't learn OOP. They never knew what is OOP. Learning new thing, specially OOP, is toooo hard for them. It is understood that VB.NET is nowhere close to VB. Although language structure and keywords are same as VB6, but VB.NET is superior and powerful. I don't understand, how in the world Microsoft thought that VB guys can migrate to VB.NET? I don't think those people can migrate to Delphi as well. Although Delphi is easier to learn, it is still based on true OO language, Object Pascal. For VB guys, it doesn't matter what language they are going to migrate. What really matters is, they are used to play with non-OOP. Migrating to Delphi ain't easy for them. Understanding VCL is not a child's play. They will never know why Delphi is superior than VB. They will never understand why VB can't make single EXE, Why Delphi is called true 'RAD'! I used to show to my friends 'what Delphi can do'. They keep asking me 'if Delphi can make single EXE, no runtime, why Microsoft can't do this with VB?' They added 'Delphi is also producing application for Windows as VB does.' I used to answer them 'If you have your house to be built strong, it's foundation must be strong.' That's what Borland did. Unlike Microsoft, Borland didn't leave its user nowhere. Current version of Delphi, 2005, still supports Win 32 application development. Where would all those VB guys go if they want to do Win32 stuff? Use same 4 or 5 yrs old VB6? It is sure that Win32 gonna live more. People still prefer Win32 application than .NET's Winform application, because it needs .NET runtime to be installed, which is huge download. More, Delphi now supports .NET application development, either Winform or ASP.NET. Delphi developers who want to learn .NET just have to learn about framework. Although Microsoft is large fish, but they should not under estimate medium fish. :-)

Thursday, March 24, 2005

Friday, March 04, 2005

On Finalizers and Destructors

I've been reading much on Finalizers and Destructors in Delphi for .NET because I wanted to understand garbage collection mechanism in depth. After reading couple of blog entries, I got confused. I used to use try...finally block in Delphi 7. I read that .NET doesn't require object to be destroyed as it uses automatic garbage collection method. I asked myself, do I still need to use try...finally method in Delphi 8? Finally, Nick's blog entry made everything clear. It says : "So, bottom line: Continue to call Free on the classes you create in your .Net applications. If there's no need for a Free call, no harm done. If there is a need for a Free call, then you've done it, and all is well. " There are some more articles which explain everything about GC or object destruction in .NET http://bdn.borland.com/article/0,1410,29365,00.html http://www.ftponline.com/vsm/2002_12/magazine/features/balena/default_pf.aspx

Friday, February 25, 2005

My project on SourceForge.net

When Delphi 8 came out, I was really excited to build small project in ASP.NET in it. I decided to make small application to keep track of developer's time. So, after a month, initial version of my first ASP.NET application, WorkLog Application, is ready to use. At first, I didn't have clue, how to start project in this 8th version of Delphi, because it is only for .NET framework. Eventhough I've been using Delphi for years, my experience is only with Win32 application development. I then found very good demo application of Delphi 8 in About Delphi Programming site. After downloading BDSWebExample and studing it's code, everything is clear to me. Also, not to forget, there are some good articles on same site for Delphi for .NET. Again, I used to read Borland's newgroup for more information on Delphi 8. After starting my project, I started finding problem with some objects. I didn't have any book and inforamtion on about.com is very limited. So, I started looking into .NET framework help file. Although all the examples are in C# or VB.NET, I was able to translet them for Delphi. So, there is no more problem for reference anymore. While developing this project, I wanted to try something else. First of all, I wanted to try assembly written in C#. So, I wrote some routines in C# Builder and made an assembly. I successfully used all the routines defined in that assembly. Second, I wanted to try third party component in my application. At the same time I was looking for popup calender for reporting. I found this great control called Calendar Popup and succesfully used it. Finally, I've decided to put this project in public domain so that other can get idea on how to do Delphi in .NET. You can find more information on this project from it's homepage. You can download latest version from here.

Tuesday, February 15, 2005

Got Married

It's been more than month since I last posted in this blog. I was away from computer and busy getting married. Finally, I got married on Jan 22nd with my girl friend Sajana. We have been together for last 4 years. Just after the week of marriage, when we were leaving on our honeymoon, there was an incident in Nepal. King took over and everything was shut down. We were totally cut off from outside world. It took 7 days to restore communication. Life was really painful when telephone, Internet were not working. Still, mobile phones and wireless communication are not working. When everything worked, it was too late for our honeymoon. We both resumed our job already. Now, life is normal, at least in Kathmandu and we are planning for our honeymoon. ;-)

Monday, January 10, 2005

Delphi for .NET Developer's Guide

Thanks to my brother, who is living in Australia now, I got a copy of Xavier Pacheco's Delphi for .NET Developer's Guide. This book is the only one book for Delphi for .NET(at least for now). I was trying to get this book from India, but Sam's Publication has already discontinued it's publication for South Asian country. I've read so many good reviews about this book in amazon and wanted a copy very badly. After going through some chapters I also think this is a book you need if you want to get started with .NET using Delphi as your language. I will be writing more on this book in coming days.