Friday, May 28, 2010

Making Uninstaller for vb.net Application

VS2005 Code
-----------
Deployment VB.NET project (with uninstall file)
In Visual Studio.NET:
Ø File > Add Project > New Project > Setup & Deployment Project > Setup Project
(Enter name and location)
Ø Add (right-click in Application Folder > Add > Project Output):
· Primary Output
Ø If an error occurs about files that should be excluded > In Solution Explorer select your Setup project > Exclude those files (right-click > exclude)

Ø Build > Build ’name project’

In Windows:
-----------
Ø Create an Uninstall.bat file containing:
C:\WINDOWS\system32\MsiExec.exe /I{productcode}

(Path depends of your Windows version, check where your system32 folder is located)
(You’ll find the productcode in Visual Studio.NET > Tab Properties in the setup project you’ve just created)

Ø Open the setup project in Visual Studio.NET if you closed it
Ø Add (right-click in Application Folder):
· Add > Project Output > File > Uninstall.bat
· Create New Shortcut > Application Folder > Primary Output (enter a name)
· Create New Shortcut > Application Folder > Uninstall.bat (enter a name)
· Add > File > add .ico files you want to use for the shortcuts
Ø Shortcuts properties > ‘icon’ property (use the icons you’ve just added)
Ø Move the shortcuts to User’s Desktop/User’s Programs Menu (you can also create subfolders)
Ø Build > Rebuild ’name project’

Tuesday, May 25, 2010

Display Custome Message on Crystal Report Textbox

Dim objRpt As New rptAppoinment
Dim myMsg As CrystalDecisions.CrystalReports.Engine.TextObject

myMsg = CType(objRpt.ReportDefinition.ReportObjects.Item("Text8"), CrystalDecisions.CrystalReports.Engine.TextObject)

myMsg.Text = "This is my custom message in Crystal Report."

Fill ListView with SQL Server Database Record

CN.ConnectionString = "Data Source = " & System.Environment.MachineName & "\SQLEXPRESS; Initial Catalog = YourDB;Integrated Security = True"

CN.Open()

Dim strSQL As String
Ds.Clear()

strSQL = "SELECT Field1, Field2 FROM TableName"
Da = New SqlDataAdapter(strSQL, CN)
Da.Fill(Ds, "TableName")
CN.Close()
MaxRows = Ds.Tables("TableName").Rows.Count
inc = -1

If MaxRows = 0 Then
MsgBox("No record found for your search!", MsgBoxStyle.Information)
Ds.Clear()
ListView1.Clear()
Exit Sub
Else
ListView1.Clear()
ListView1.View = View.Details
Dim dt As DataTable = Ds.Tables("TableName")

For Each c As DataColumn In dt.Columns
ListView1.Columns.Add(c.ColumnName, 100)
Next

For Each r As DataRow In dt.Rows
Dim item As New ListViewItem(r(0).ToString())
For i As Integer = 1 To dt.Columns.Count - 1
item.SubItems.Add(r(i))
Next
ListView1.Items.Add(item)
Next
End If

If CN.State = ConnectionState.Open Then CN.Close()

Wednesday, May 19, 2010

Declare Global Variables in VB.NET and C#

C#
-----
namespace Module{
public class Module1
{
public static int moduleinteger;
}
}

access like Module1.moduleinteger


VB.net
------
Module Module1
Public moduleinteger As Integer
End Module