Tuesday, March 28, 2006

CPS tried Singleton form in vb.net

We all get one object each time a constructor is called. If we call a class' constructor three times, we get three instances of the class. Also even if we don't write a constructor in our class, the VB.NET compiler creates a no-argument. However, if a class does have a constructor, whether it is a no-argument constructor or one that accepts arguments, the VB.NET compiler does not create a new one. Normally, these constructors have a public access modifier because they are meant to be invoked from outside of the class.
But sometimes there are cases where we want to limit the number of instances of a class to one. When we Press win+ R in windows XP ( I am using windows xp) it will display a RUN dialog. But when it loaded if we press Win + R button again and again we will get only one RUN dialog. How can we do this in vb.net? The Singleton pattern can be used for this purpose. This pattern is effective for limiting the maximum number of instances of a class to exactly one.

Imports System
Imports System.Windows.Forms
Imports System.ComponentModel

Public Class SingletonForm : Inherits Form

Private Shared myInstance As SingletonForm


#Region " Windows Form Designer generated code "

Private Sub New()
MyBase.New()
InitializeComponent()
End Sub

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase
.Dispose(disposing)
End Sub

Me.Name = "SingletonForm"
Me.Text = " CPS Tried Singleton Form "
Me.Width = 450
Me.Height = 150
End Sub
#End Region


Protected Overrides Sub OnClosing (ByVal e As CancelEventArgs)
e.Cancel = True
Me.Hide()
End Sub

Public Shared Function GetInstance() As SingletonForm
If myInstance Is Nothing Then
myInstance = New SingletonForm
End If
Return myInstance
End Function
End Class



Using Sigleton form


Public Class UsingSingletonform
Inherits System.Windows.Forms.Form

Private Sub New()
MyBase.New()
InitializeComponent()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim CPSsingleton As SingletonForm = SingletonForm.GetInstance()
CPSsingleton.Show()
End Sub

Public Shared Sub Main()
Application.Run(New UsingSingletonform)
End Sub
End Class



Saturday, March 25, 2006

Finally I got Atlas again

I read about Atlas project in 2005 july or augest @ news.com.and i was lookng @ Atlas Project for more infomations.But wonder i have missed that.i do not know how(may be i was away from web Last 5 months.Sadly i coudnt come online :( ).Anyhow my buddy Charith helped me to Find it again.@ last i got it again.so like to say visit here for more information. So charith thank you once again.

Friday, March 24, 2006

Are you Interested in ORM tools ?

I think I have mentioned about ORM( object Relational Mappers) in here some time ago.But I got a nice artical about how to Select a good ORM tool. it's name goes as How-To-Select an Object-Relational Mapping Tool for .NET . There are about 15 Tools. I have already used some of them.I loved some of them, like My Generation , NHibernate before.But there are some more.

And I got another Great artical about Data Modeling.it's great. try it guys/gals.

aloha, my blog is going to be a Database Blog .......... I have to stop writing about Databases lol

Wednesday, March 22, 2006

Bloggers Meetup ...

Y'day My buddy charith wanted me to be @ Barefoot.So finally I got there. As a Sri lankan Charith got Late(around 30 mints.) Now don't kick my A**.Charith ,Casper and I hanged around barefoot cafe till Razor came to the picture.After Razor's Arrival we met Indi.So hiiiiiii indi ;) Until Wela came it was boring. We were about to leave isn't it?
I met some people for the first time in ma life.But I have read about them before.It's nice to meet u guys.Lot of open source guys were there.Mahangu, Dilantha, Chamil and many more. and I'm very glad to meet The DOTNET guy, wela. :)

More commentary about the meetup.....

Wela, (with some cool pictures).
Charith, (with stolen pictures from wela)
Razor
Mahangu (The open sorce)
Dilantha (A nice guy. I like his way of talking)

Tuesday, March 21, 2006

Did you Try to Create Reports in SQL Server 2005

I just went through Report Option in SQL server 2005. It looks good, can do a lot of things on it just like crystal report.But we can't compare it. b'coz Crystal Reports only for Reporting isn't it?.So Here is some screens which I did.i think You have to Use Business Intelligence Development Studio which is in SQL server 2005. If you need more information about Business Intelligence and Data Warehousing in SQL Server 2005 just click here



How is it? you can Set Server URL for Report Engine In project properties.Then You can view the Report in Internet Explorer

Wednesday, March 15, 2006

What happened to my Domain name?

I wanted to buy a Domain name CPS.net or .com as my Home page. But it's already taken. So I decided to buy Chaminda.net Last December. But b’coz of some problems I postponed that. Actually I forgot to resolve. I wanted to buy it Today. Gone mad it is not available now. I am sure it was available till January. B’coz I checked about it. So I am warning you all. If u want to buy a domain name do it ASAP. Otherwise it will no longer be available. So do it today.

Monday, March 13, 2006

I don't know whats wrong with me!

I haven’t done anything since last Friday. I didn’t open Sql server or visual studio for the weekend. I do not know what i was doing in the weekends. Didn’t go through a book even. I have to complete thousands of work. What’s wrong with me? Can’t I change my Mind?? :(

Friday, March 10, 2006

Got my new Mobile

i sold my Old Nokia 6260 and was hanging without a mobile the last 2 weeks.b'coz Softlogic had no stock of nokia 6630.finallyI got my new Nokia 6630 Today.It's not da Phone which i was dreaming.i was dreaming about Sony Ericsson W800 or a K750i.but it was tooo expensive :( so i changed ma mind and thought to buy a 6630.but it's great.it has a nice Head set with good sound quality.i think i can use my mobile as a mp3 player.it's great.now i am searching for a mp3 player with a equalizer for my mobile.i have to say it again it's a great mobile which i ever used.

Thursday, March 09, 2006

It's interesting to work with sql Server 2005

I imported Some of my sql server 2000 Databases In to new Sql server 2005.i saw something new in sql TOP Key word.The TOP operator has been around since SQL Server 7.0( i think so.), in the past it only accepted a constant as the number of rows to return or as the percentage of the rows to return. The TOP statement in SQL Server 7.0 and SQL Server 2000 was also limited to SELECT statements. Thanks to improvements in the TOP operator for SQL Server 2005, the TOP statement can now accept variables and subqueries for the number of rows to return or the percentage of the rows to return. The TOP operator has also been enhanced so that it can be used with INSERT, UPDATE, and DELETE statements in addition to the SELECT statement.

DECLARE @intRows INTEGER;
DECLARE @startAfter INTEGER;
SET @intRows = 12 ;
SET @startAfter = 10;
SELECT TOP (@intRows) * FROM HumanResources.Employee
WHERE EmployeeID > @startAfter
ORDER BY EmployeeID;
GO


And we Can set Varible Values programicaly.

We can still use the PERCENT keyword to return a percentage of rows instead of a fixed number of rows. And sql server 2005 we can use it with Top keyword with a variable value.

DECLARE @intPercRows INTEGER
DECLARE @intPage INTEGER
SET @intPercRows = 12
SET @intPage = 10
SELECT TOP (@intPercRows) PERCENT * FROM HumanResources.Employee
WHERE EmployeeID > @intPage
ORDER BY EmployeeID;
GO



In addition to passing an expression, we can also use a subquery to satisfy the TOP statement value requirement.

DECLARE @startAfter INTEGER;
SET @startAfter = 0;
SELECT TOP (SELECT COUNT(*)/11 FROM HumanResources.Employee) *
FROM HumanResources.Employee
WHERE EmployeeID > @startAfter
ORDER BY EmployeeID;
GO

Wednesday, March 08, 2006

First Day in Sql 2005

First time i Enter in to sql 2005.Where is that Enterprise Manager,Query Analyzer and Analysis Manager Short cuts?? They have remove them and introduce a new interface call SQL Server Management Studio.its a new integrated tool that combines the functionality of three tools: Query Analyzer, Enterprise Manager, and Analysis Manager. In addition, it allows us to manage all other components, such as Reporting Services, SQL Server Integration Services (SSIS; formerly known as DTS), Notification Services, and SQL Server Mobile. WOW.......


and it has Template Explorer.we can can lot of Templates for various sql functions from this Template Explorer. So what else we need??? .let me go through and find out ;)

Tuesday, March 07, 2006

working with Sql server 2005

I installed sql server 2005 Work group Edition at my home compuater last december. but Still i could not work on it well.i thot to start it today.yeah it has great new features with a reporting Server. so ?? lets move

Monday, March 06, 2006

Back to blogger.com

It's all Most 5 months from my last blog entry.could not write here i do not know wot happned ? Did some Smart clients project for the company with web service support.hmmmmm it was a great Opportunity to me.i learn lot of things from it.

So ? it's great to back in blogspot. :)