#AdditionalJar: jtds-1.3.1.jar
Sub Process_Globals
Dim CSE As CallSubExtended
Dim mssql As JdbcSQL
Dim driver As String = "net.sourceforge.jtds.jdbc.Driver"
Dim jdbcUrl As String = "jdbc:jtds:sqlserver://" & SQLServerSTR & "/" & SQLdatabase
End Sub
Sub Button1_Click
CSE.AsyncCallSubx(Me, "Update_SQLiN", Null, 5)
End Sub
Sub Update_SQLiN
CSE.RunOnMainThread("Add_txt",Array As String("Update_SQLiN"))
CSE.AsyncCallSubx(Me, "Get_Customers", Null, 5)
End Sub
Sub Add_txt(txt)
Label1.Visible=True
Label1.Text=Label1.Text & CRLF & txt
Label1.Invalidate
End Sub
Sub Get_Customers
Dim L3C As List
L3C.Initialize
If mssql.IsInitialized=False Then
Connect_A
Wait For mssql_Ready (Success As Boolean)
End If
wait for(ReturnRS("select columns from table")) complete (EmpJRS1 As JdbcResultSet)
Rs2L(EmpJRS1,L3C,False,False)
Log("Customers_finished")
End Sub
Sub Connect_A
If L.IsInitialized=False Then L.Initialize
If mssql.IsInitialized=False Then mssql.InitializeAsync("mssql", driver, jdbcUrl, SQLusername, SQLpassword)
Log("Connect_A")
End Sub
Sub mssql_Ready (Success As Boolean)
If Success = False Then
Log("Check unfiltered logs for JDBC errors.")
End If
Return Success
End Sub
Sub Rs2L(RSJ As JdbcResultSet, JL As List, Simple As Boolean, GetColumns As Boolean)
Log("Rs2L")
Try
If JL.IsInitialized=False Then JL.Initialize
JL.Clear
Catch
Log("Rs2La")
'CSE.RunOnMainThread("error_do2",Array As String("1a " & LastException.Message))
End Try
Try
If GetColumns=True Then
Dim Item1 As List
If Item1.IsInitialized=False Then Item1.Initialize
Item1.Clear
For i=0 To RSJ.ColumnCount-1
Item1.add(RSJ.GetColumnName(i))
Next
JL.Add(Item1)
End If
Catch
Log("Rs2Lb")
'CSE.RunOnMainThread("error_do2",Array As String("1b " & LastException.Message))
End Try
If Simple=True Then
Try
Do While RSJ.NextRow
For f=0 To RSJ.ColumnCount-1
JL.Add(RSJ.GetString2(f))
Log(RSJ.GetString2(f))
Next
Loop
Catch
Log("Rs2Lc")
'CSE.RunOnMainThread("error_do2",Array As String("1c " & LastException.Message))
End Try
Else
Do While RSJ.NextRow
Try
Dim Item1 As List
If Item1.IsInitialized=False Then Item1.Initialize
Item1.Clear
Catch
Log("Rs2Ld")
'CSE.RunOnMainThread("error_do2",Array As String("1d " & LastException.Message))
End Try
Try
For i=0 To RSJ.ColumnCount-1
Item1.add(RSJ.GetString2(i))
Next
Catch
Log("Rs2Le")
'CSE.RunOnMainThread("error_do2",Array As String("1e " & LastException.Message))
End Try
Try
JL.Add(Item1)
Catch
Log("Rs2Lf")
'CSE.RunOnMainThread("error_do2",Array As String("1f " & LastException.Message))
End Try
Loop
End If
RSJ.Close
Log("Rs2L-finish")
End Sub