Showing posts with label Crystal Report Parameter value VB.NET. Show all posts
Showing posts with label Crystal Report Parameter value VB.NET. Show all posts

Tuesday, December 04, 2007

Detecting Whether the Application is Already Running

Recently a colegue of mine needed to know how he can determine whether his application is already running in the machine at application start.

Using this post I am going to share the solution with you all, showing how you can determine whether your application is already running in the computer. By detecting this either you can stop starting of the second instance of the application and activate the already running application for the user or you can attempt to close the earlier application and start the new one. If you does not check this then multiple applications might start and the user might complain about the application performance. Also this may cause problems occurring from locked resources.

* Visual Basic (VB)
Using VB you can easily check this by using the App object.
------------------------------------------------------------
If App.PrevInstance = True Then
MsgBox("The program '" & App.EXEName & "'is already running. Please use the running application.")
End
End If
------------------------------------------------------------

* Visual Basic .NET (VB.NET)
Using VB.NET you can do this by using Diagnostics.Process class.
------------------------------------------------------------
If Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess().ProcessName).Length > 1 Then
Application.Exit()
End If
------------------------------------------------------------

Wednesday, October 11, 2006

Getting a Crystal Report Parameter value in VB.NET

After setting a parameter value of a crystal report there is no easy way of getting the value. So I found this to get the parameter value.


CType(CType (CType (CType (CType (CType (rpt.Parameter_paraArea, CrystalDecisions.Shared.IParameterField), CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition).CurrentValues, CrystalDecisions.Shared.ParameterValues).Item(0), CrystalDecisions.Shared.ParameterValue), CrystalDecisions.Shared.ParameterDiscreteValue).Value, Object)

rpt is the Crystal Report, paraArea is my parameter name which I needed to get the value of.

Hope this helps.