G gacar Active Member Oct 17, 2021 #1 This way only return last value in the table. How can i get only single value from a database table eg 5.row 3.column value or selected row 3.column value. Thanks Code: Dim rs As JdbcResultSet = SQL.execquery("select * FROM Bolge") Do While rs.nextrow LabelIstanbul.Text = rs.getstring2(2) Loop rs.Close
This way only return last value in the table. How can i get only single value from a database table eg 5.row 3.column value or selected row 3.column value. Thanks Code: Dim rs As JdbcResultSet = SQL.execquery("select * FROM Bolge") Do While rs.nextrow LabelIstanbul.Text = rs.getstring2(2) Loop rs.Close
Solution Erel Oct 18, 2021 Code: Dim rs As JdbcResultSet = SQL.execquery("select * FROM Bolge") Dim rowIndex As Int Do While rs.nextrow If rowIndex = 4 Then LabelIstanbul.Text = rs.getstring2(2) rowIndex = rowIndex + 1 Loop rs.Close Better solution is to add a WHERE clause and get the relevant value.
Code: Dim rs As JdbcResultSet = SQL.execquery("select * FROM Bolge") Dim rowIndex As Int Do While rs.nextrow If rowIndex = 4 Then LabelIstanbul.Text = rs.getstring2(2) rowIndex = rowIndex + 1 Loop rs.Close Better solution is to add a WHERE clause and get the relevant value.
Erel B4X founder Staff member Licensed User Longtime User Oct 18, 2021 #2 Code: Dim rs As JdbcResultSet = SQL.execquery("select * FROM Bolge") Dim rowIndex As Int Do While rs.nextrow If rowIndex = 4 Then LabelIstanbul.Text = rs.getstring2(2) rowIndex = rowIndex + 1 Loop rs.Close Better solution is to add a WHERE clause and get the relevant value. Upvote 0 Solution
Code: Dim rs As JdbcResultSet = SQL.execquery("select * FROM Bolge") Dim rowIndex As Int Do While rs.nextrow If rowIndex = 4 Then LabelIstanbul.Text = rs.getstring2(2) rowIndex = rowIndex + 1 Loop rs.Close Better solution is to add a WHERE clause and get the relevant value.
M Mahares Expert Licensed User Longtime User Oct 18, 2021 #3 gacar said: eg 5.row 3.column value Click to expand... Another quick way: Code: Dim rs As JdbcResultSet = SQL.execquery("select * FROM Bolge LIMIT 1 OFFSET 4") '5th row If rs.nextrow then LabelIstanbul.Text = rs.getstring2(2) End If rs.Close Upvote 0
gacar said: eg 5.row 3.column value Click to expand... Another quick way: Code: Dim rs As JdbcResultSet = SQL.execquery("select * FROM Bolge LIMIT 1 OFFSET 4") '5th row If rs.nextrow then LabelIstanbul.Text = rs.getstring2(2) End If rs.Close
Erel B4X founder Staff member Licensed User Longtime User Oct 18, 2021 #4 (This is a valid solution but it is a bit fragile. Relying on the intrinsic order of the table is dangerous.) Upvote 0
(This is a valid solution but it is a bit fragile. Relying on the intrinsic order of the table is dangerous.)
M Mahares Expert Licensed User Longtime User Oct 18, 2021 #5 Erel said: it is a bit fragile Click to expand... You are correct . Normally you like to have an ORDER BY clause included, but I did not want to deviate from the OP question. Upvote 0
Erel said: it is a bit fragile Click to expand... You are correct . Normally you like to have an ORDER BY clause included, but I did not want to deviate from the OP question.
M Mahares Expert Licensed User Longtime User Oct 19, 2021 #6 Erel said: Relying on the intrinsic order of the table is dangerous Click to expand... To understand this better, doesn't the code in post #2 also rely on intrinsic order since no order by was provided and can cause the same issue as post #3. Upvote 0
Erel said: Relying on the intrinsic order of the table is dangerous Click to expand... To understand this better, doesn't the code in post #2 also rely on intrinsic order since no order by was provided and can cause the same issue as post #3.
Erel B4X founder Staff member Licensed User Longtime User Oct 19, 2021 #7 Mahares said: To understand this better, doesn't the code in post #2 also rely on intrinsic order since no order by was provided and can cause the same issue as post #3. Click to expand... You are 100% correct. This is why I added: "Better solution is to add a WHERE clause and get the relevant value." Upvote 0
Mahares said: To understand this better, doesn't the code in post #2 also rely on intrinsic order since no order by was provided and can cause the same issue as post #3. Click to expand... You are 100% correct. This is why I added: "Better solution is to add a WHERE clause and get the relevant value."