Suhail Kaleem » suhail kaleem
suhail kaleem

suhail kaleem

(0 comments, 4 posts)

This user hasn't shared any profile information

Home page: http://kaleemsoft.com

Posts by suhail kaleem

RemovePreviousVersions not working

0

In visual studio 2010 while creating setup package when you select RemovePreviousVersions = true

even then the old application installed is not removed  in order to fix that

save the below vbs code in project directory


Dim objInstaller
 Dim objDatabase
 Dim objView
 Dim objResult

Dim strPathMsi

If WScript.Arguments.Count <> 1 Then
 WScript.Echo "Usage: cscript fixRemovePreviousVersions.vbs "
 WScript.Quit -1
 End If

strPathMsi = WScript.Arguments(0)

Set objInstaller = CreateObject("WindowsInstaller.Installer")
 Set objDatabase = objInstaller.OpenDatabase(strPathMsi, 1)
 Set objView = objDatabase.OpenView("UPDATE InstallExecuteSequence SET Sequence=1450 WHERE Action='RemoveExistingProducts'")

WScript.Echo "Patching install sequence: UPDATE InstallExecuteSequence SET Sequence=1450 WHERE Action='RemoveExistingProducts'"
 objView.Execute
 objDatabase.Commit

WScript.Quit 0

save the file with name  fixRemovePreviousVersions.vbs

now in vs 2010 set PostBuildEvent  to  cscript “$(ProjectDir)fixRemovePreviousVersions.vbs $(BuiltOuputPath)”

PostBuildEvent  can be found in setup project properties

Now build you msi and it will patch the msi and now the previous installed version will be removed.

Get months list between two dates

0

Following function  will  get a list of months  with days remaining in those months  when start date and end dates are provided


Shared Function GetMonthsList(StartDate As Date, EndDate As Date) As ArrayList

Try

Dim dt As Date = StartDate
Dim edt As Date = EndDate

Dim ar As New ArrayList
Dim str As New StringBuilder

While dt < edt

str.Append(dt.Date.ToString("MMMM yyyy"))
str.Append(",")
Dim dt2 As Date = dt.AddMonths(1)

If dt2 > edt Then
Dim minusdays As Integer = DateDiff(DateInterval.Day, dt, edt)
str.Append(minusdays + 1)
ar.Add(str.ToString)
Exit While
End If

Dim remainingdays As Integer = System.DateTime.DaysInMonth(dt.Year, dt.Month) - dt.Day
str.Append(remainingdays + 1)

ar.Add(str.ToString)
dt = dt.AddDays(remainingdays + 1)
str.Clear()
End While

Return ar

Catch ex As Exception
Throw ex
End Try
End Function

Use can use this functions as


GetMonthsList(Date.Parse("1/4/2012"),Date.Parse("4/30/2012"))

this will output

January 2012,28
February 2012,29
March 2012,31
April 2012,30

extract date from datetime and then compare with date field

0

MSSQL 2005 does not have DATE datatype only datetime and smalldatetime

datetime will return date and time

where as ms sql 2008 have DATE datatype which makes it easy to extract date

mysql also have DATE datatype

for mssql 2005

following is the code to extract  just the date part from datetime field

i will be using getdate function  to get current date time you can replace getdate() with datetime field name

Cast(Floor(Cast(GetDate() As Float)) As DateTime)

this will extract date from datetime field

and this how you compare

select * from YourTable where

Cast(Floor(Cast(GetDate() As Float)) As DateTime) > YourDateTImeField

suhail kaleem's RSS Feed
Go to Top