B4J Question Display of SQL data incorrect

Peter Lewis

Active Member
Licensed User
Longtime User
Hi All

I do not know what it is displaying, there is nothing in the debug to tell me what it is doing , It seems like it is putting some driver info and one for each record read.

The result is attached to this post.

I am sure it is something I have missed along the way.

Any advice would be helpful

Thank you in advance





B4X:
#Region Project Attributes
    #MainFormWidth: 1024
    #MainFormHeight: 768
    #AdditionalJar: mysql-connector-java-5.1.41-bin
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private Sql1 As SQL
    Private ListView1 As ListView
   
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("1") 'Load the layout file.
    MainForm.Show
   
    Sql1.Initialize2("com.mysql.jdbc.Driver", "jdbc:mysql://162.215.252.76:3306/himelcoz_diamonds", "himelcoz_testing", "ZXNb^iVIP1_=")

    Dim rs As ResultSet = Sql1.ExecQuery("SELECT CustNo FROM Customer")
    Do While rs.NextRow
        ListView1.Items.Add(rs)
    Loop
    rs.Close
End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub
 

rboeck

Well-Known Member
Licensed User
Longtime User
With 'Dim rs as Resultset' you create an object, which is not a string - you have to use rs.GetString("col2") or rs.Getlong ... or ..., to get the fields of the resultset.
 
Upvote 0

Peter Lewis

Active Member
Licensed User
Longtime User
Hi

This worked

B4X:
        ListView1.Items.Add(rs.GetString("barc") &"    "& rs.GetString("location" ))
        ListView1.Items.Add(rs.GetString("location"))
        ListView1.Items.Add(rs.GetString("signature"))
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…