#Region Project Attributes
#AdditionalJar: jtds-1.3.1.jar
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim sql1 As JdbcSQL', Str As StringUtils
End Sub
'I use Callback to tell me what sub to return to if the connection fails and I have to re-establish it.
Public Sub Connect(CallBack As String)
sql1.Close
sql1.InitializeAsync("Connect", "net.sourceforge.jtds.jdbc.Driver", "jdbc:jtds:sqlserver://192.168.1.5:65218;databaseName=MyDBName;user=UserName;password=MyPW;appname=SKMJL;wsid=MyWS;loginTimeout=10", "UserName", "MyPW") 'sql 2012
Catch
Msgbox2Async("Connection to the network failed: " & CRLF & LastException.Message , "Network Error", "OK","","", Null, True)
End Try
End Sub
'I have left an example SQL Select statement in here, ExecQueryAsync
Sub Connect_Ready (Success As Boolean)
ProgressDialogHide
If Success = False Then
MsgboxAsync("Failed connect to the server. Server is not available, database is not availble, connect string is wrong, or you are having network/firewall issues. Contact your system administrator.", "Network/SQL Error")
MsgboxAsync(LastException.Message,"JAva Error:")
Return
End If
Try
Connecting = False
ProgressDialogShow("Getting Configuration Data")
GetCount 'Check user counts
Dim SenderFilter As Object = sql1.ExecQueryAsync("Switches", "SELECT SW17, SW34, SW37, SW39 FROM Switches;", Null)
Wait For (SenderFilter) Switches_QueryComplete (Success2 As Boolean, Crsr As JdbcResultSet)
If Success2 = False Then
ProgressDialogHide
MsgboxAsync("Failed to get the required Configuration (Switches) data - Cannot continue." & CRLF & LastException.Message, "DB Error")
Screen = "Home"
Return
End If
Catch
Log(LastException.Message)
ToastMessageShow("Connect_Ready" & CRLF & LastException.Message, True)
End Try
End Sub