Installing .net 1.1 on Windows 7

January 14, 2010

Hello world!

September 15, 2009

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

How to delete duplicate rows when primary key is not present

September 4, 2009
 
Yesterday, my client I asked me to delete duplicate rows from an SQL table, easy task I thought first.. I tried following SQL query but it just replicated the whole table still containing the bad rows.
 
SELECT Disctinct * INTO Inventory1
FROM Inventory
 
hmm, googled for the solution, most the solutions i found were for the table having a primary key defined. Which was not the case with me. Luckly i found this webpage: http://www.kodyaz.com/articles/delete-duplicate-records-rows-in-a-table.aspx , in which author metioned couple of different ways of achiving the same.
 
 

Kids celebrating independence day :)

August 21, 2009

Attaching SQL database programmatically

July 6, 2009

After getting tired up with the all installer and "installer experts", my client asked me to write some code to check and attach the SQL Express db on Application startup.
For this, I had a very vague idea – but i had heard something called SMO (SQL Server Management Objects), so i tried google which as usual put me on the right track.

Below is the code to attach SQL mdf file programmatically. VocabEx is the name of database user want to attach. Reference to the assemblies required are:

Microsoft.SqlServer.Smo.dll
Microsoft.SqlServer.SqlEnum.dll
Microsoft.SqlServer.SmoEnum.dll
Microsoft.SqlServer.ConnectionInfo.dll

These assemblies can be found in: <installation directory>:Program FilesMicrosoft SQL Server90SDKAssemblies folder

Dim sqlServer As New Server(".SQLExpress")
Dim sqlServerConn As ServerConnection = sqlServer.ConnectionContext

‘TRUE for using integrated security mode otherwise use sqlServerConn.Login and sqlServerConn.Password
sqlServerConn.LoginSecure = True

sqlServerConn.DatabaseName = "master"

‘Check to see if database already exists
If Not sqlServer.Databases("VocabEx") Is Nothing Then
         
MsgBox("DB Already Exists")
          Return
End If

Dim db As Database = New Database(sqlServer, "VocabEx")
Dim fg As FileGroup = New FileGroup(db, "PRIMARY")

db.FileGroups.Add(fg)

Dim dbFile As DataFile = New DataFile(fg, "VocabEx")
fg.Files.Add(dbFile)

dbFile.FileName = "c:dataVocabEx.mdf"

Dim dbLogFile As LogFile = New LogFile(db, "VocabEx_log")
db.LogFiles.Add(dbLogFile)
dbLogFile.FileName = "c:dataVocabEx_log.ldf"

Dim dbColl As New System.Collections.Specialized.StringCollection
dbColl.Add(dbFile.FileName)
dbColl.Add(dbLogFile.FileName)

sqlServer.AttachDatabase("VocabEx", dbColl)

Shikwa by Allama Muhammad Iqbal – A master piece

March 18, 2009

>

 

 

Automatically change the dll/exe version on every build

February 6, 2009
hmm, few days ago I was wondering how to automatically change the ‘build part’ of version number automatically on every build of .net project within visual studio, I had a rough idea that it has to do some thing with AssemblyInfo.cs file. And yes I guessed it right.
There are two entries regarding Assembly versioning:

[assembly: AssemblyVersion("1.0.0.0")]
[assembly:
AssemblyFileVersion("1.0.0.0")]

Delete the AssemblyFileVersion entry and change the AssemblyVersion to something like this:

[assembly:

AssemblyVersion("1.0.0.*")]

now build the program from visual studio and check the property of your output file, it will display something like: 1.0.0.35568, bingo!

Date comparision without time – SQL Server

February 6, 2009
While working on a point of sales system for one of my customer, I was very often in need to fetch records from SQL database based on the current date. SQL saves Date in DateTime format i.e. MM/DD/YYYY HH:MM:SS, which caused a real problem in my ___.
The solution i found is:
CAST(FLOOR(CAST( getdate() AS float)) AS datetime)
which returns “YYYY-MM-DD 00:00:00.000″ – the date without the time.
 

Norway is calling…

December 8, 2008
After reading this post, you will perhaps start believing in destiny..hmm because my journey from Karachi to Trondheim is more stranger than interesting.
There is ‘The Hitler’ in everyone but Hilter inside me I guess was more patriotic. Which always made me to consider Germany as my second homeland. Many times in my dreams I saw myself speaking pure german (tough its true tht I don speak pure Urdu), saw my hybel somewhere in small town of Munich etc…Pursuing my MS degree from Germnay was more than a wish to me. But here destiny played it’s part, when the admission time came I didnt even file a single application to any german university, why? continue reading you will get the answer.
One day Zaheer told me tht he is going to register for IELTS, i said ok let’s go and thanks to my super 70cc bike we were standing in front of AEIO(i still dont remeber, wether its AEOU or AEIO, whatever)…. when we came out from their office, guess what, instead of Zaheer i registered for the test with a mind to apply for UK instead (MS degree with GBP running allover my mind)…
 
 
to be continue

My stay in Trondheim

October 19, 2008
Hello,
 
I am going to start writting my experience here in Trondheim, Norway while I am here in NTNU as an International Student, enrolled in internation masters in information systems.
 
I will try to write my weekly activities and attach some related photographs….
 
I hope you will find my diary/blog interesting and helpful…
 
12082008(006)