Android Question Question about getting values from a variable

padvou

Active Member
Licensed User
Longtime User
Hello.
If you take a look at the picture, "L" is a variable defined as list in my application.
How can I access the values seen in the picture?
For example the value of rowsInResult which is 1.

Thank you
 

padvou

Active Member
Licensed User
Longtime User
You mean L.Size ?
Normally, yes.
But I notice now that I get an error when asking for L.size:
java.lang.ClassCastException: net.sourceforge.jtds.jdbc.JtdsResultSet cannot be cast to java.util.List
 
Upvote 0

padvou

Active Member
Licensed User
Longtime User
I changed the L as List to L as JdbcResultSet but the question remains as to how I can read the values from the names as shown in the initial picture.
 
Upvote 0

padvou

Active Member
Licensed User
Longtime User
It has to be:
B4X:
dim g as  JdbcResultSet
although I do not use it often .

B4X:
Do While L.NextRow
  log(g.GetString("fieldname")) ' Or GetInt/GetLong.....
loop
It seems that this moves only forward. So if I need to do something more and start it from the beginning?
 
Upvote 0

padvou

Active Member
Licensed User
Longtime User
B4X:
Dim data As List
data.Initialize
Do While L.NextRow
  data.Add(Array(L.GetString("col 1"), L.GetInt("col 2"))
loop
Dim SecondRow() As Object = Data.Get(1)
Thank you Erel.
In the 4th line, can the strings be added in the array dynamically based on how many columns there are? In your example, there are two.
In the 6th line, it gets the column names?
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
t gets the column names?
B4X:
Dim data As List
    data.Initialize
    data.Add(Array(l.GetColumnName(0), l.GetColumnName(1)))  'gives you the column names in the first row
    Do While l.NextRow
        data.Add(Array(l.GetString("col 1"), l.GetInt("col2")))
    Loop
    Dim o() As Object=data.Get(0)  ' column name
    Log(o(0))   'col 1 name
    Log(o(1))   'col 2 name
 
Upvote 0

padvou

Active Member
Licensed User
Longtime User
To go back to my initial question:
L is a net.sourceforge.jtds.jdbc.JtdsResultSet
It has some values as shown in the picture.


How can I read "rowsInResult" using probably javaobject?

Dim b4xResultSet As JavaObject = L
Dim jResultSet As JavaObject = b4xResultSet.?????????
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…