Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private SQL1 As JdbcSQL
End Sub
Public Sub Initialize
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
SQL1.InitializeAsync("sql1", "net.sourceforge.jtds.jdbc.Driver", "jdbc:jtds:sqlserver://sql.bsite.net;databaseName=phazilosman_SampleDB;instance=MSSQL2016;integratedSecurity=true", "phazilosman_SampleDB", "123456")
Wait For sql1_Ready (Success As Boolean)
If Success Then
Log("Connected")
ToastMessageShow("Connected", False)
Else
Log(LastException)
End If
End Sub
Private Sub Button1_Click
Dim strSQL As String = $"SELECT TOP 10 [First Name], [Last Name], [Department] FROM [People]"$
Dim SenderFilter As Object = SQL1.ExecQueryAsync("SQL1", strSQL, Null)
Wait For (SenderFilter) SQL1_QueryComplete (Success As Boolean, RS As JdbcResultSet)
If Success Then
Dim Columns As String
For i = 0 To RS.ColumnCount - 1
Columns = Columns & IIf(i > 0, " | ", "") & RS.GetColumnName(i)
Next
Log(Columns)
Do While RS.NextRow
Log($"${RS.GetString2(0)} | ${RS.GetString2(1)} | ${RS.GetString2(2)}"$)
Loop
RS.Close
Else
Log(LastException)
End If
End Sub