Option Explicit On
Imports System.Data.SqlClient
Public Class Form1
Public myCmd As SqlCommand
Public IP as string = "YourAddress"
Public AppName = "My_App"
Public CurrentVersion As String = "1.0.1"
Public myReader As SqlDataReader
Dim MyConnection As New SqlConnection("InitialCatalog=*;" &_
"Data Source="& IP &";" & _
"User ID=*;" & _
"Password=*")
'Now that we can connect to the DB, lets check the current version
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
version()
End Sub
Public Sub version()
Dim strSQL As String
Dim i As Integer = 0
Dim NewVersion As String
strSQL = "select version from APP_Versions where app = '"& AppName &"'"
Try
MyConnection.Open()
'Create a Command object.
myCmd = MyConnection.CreateCommand
myCmd.CommandText = strSQL
myReader = myCmd.ExecuteReader()
' Put the Version number into a Var
Do While myReader.Read()
NewVersion = myReader(0).ToString
Loop
Catch ex As Exception
MsgBox(ex.Message)
Finally
MyConnection.Close()
End Try
If NewVersion > CurrentVersion Then
dim msgString as string
msgString = "There is a newer version of this Application " & vbNewLine
msgString = msgString & " Would you like to download the upgrade? "
If MsgBox(msgString , MsgBoxStyle.OKCancel) = MsgBoxResult.OK Then
Dim IE
IE = CreateObject("InternetExplorer.Application")
' this opens an Internet Explorer window to the location. Since this is an executable
' file, we should be prompted to open or save - choose open to install
With IE ' This is where you put the location of the webserver to download
.navigate("http:// " & IP & " /Location/App%20Install.msi") ' the newer version
.Visible = 1
End With
IE = Nothing
End ' this closes the application so you can install the new version
End If
End If
End Sub
End Class