Z ziomorgan Active Member Licensed User Longtime User Feb 9, 2015 #1 I'm using mysql database. If I use alias for a table column the resulset method "GetColumnName" give me the original column name instead of alias. it is normal ?
I'm using mysql database. If I use alias for a table column the resulset method "GetColumnName" give me the original column name instead of alias. it is normal ?
Erel B4X founder Staff member Licensed User Longtime User Feb 9, 2015 #2 You get the value directly from the JDBC driver, so it is most probably not a bug. Can you post the query?
You get the value directly from the JDBC driver, so it is most probably not a bug. Can you post the query?
Z ziomorgan Active Member Licensed User Longtime User Feb 9, 2015 #3 Sure, Code: DBUtils.ExecuteTableView(DBKDM, "SELECT FIELD1 AS 'ALIAS1' FROM tb1 LEFT OUTER JOIN tb2 ON (tb1.ID=tb2.ID) ORDER BY FIELD1", Null, 0, tv) this is only one but the problem is persistent for all the query (but not for SQLite)
Sure, Code: DBUtils.ExecuteTableView(DBKDM, "SELECT FIELD1 AS 'ALIAS1' FROM tb1 LEFT OUTER JOIN tb2 ON (tb1.ID=tb2.ID) ORDER BY FIELD1", Null, 0, tv) this is only one but the problem is persistent for all the query (but not for SQLite)
Erel B4X founder Staff member Licensed User Longtime User Feb 9, 2015 #4 Try this sub: Code: Sub GetColumnLabel(rs As ResultSet, index As Int) As String Dim jo As JavaObject = rs Return jo.RunMethodJO("getMetaData", Null).RunMethod("getColumnLabel", Array(index + 1)) End Sub
Try this sub: Code: Sub GetColumnLabel(rs As ResultSet, index As Int) As String Dim jo As JavaObject = rs Return jo.RunMethodJO("getMetaData", Null).RunMethod("getColumnLabel", Array(index + 1)) End Sub
Z ziomorgan Active Member Licensed User Longtime User Feb 10, 2015 #5 Works fine... You can include this change in the jSQL library so that the method GetColumnName return the correct value when working with SQLite and MySQL? I, at the time, I solved by changing DBUtils: Code: For i = 0 To cur.ColumnCount - 1 Dim ColName As String If DBType = DBMYSQL Then ColName = GetColumnLabel(cur, i) Else ColName = cur.GetColumnName(i) End If cols.Add(ColName) Next thanks
Works fine... You can include this change in the jSQL library so that the method GetColumnName return the correct value when working with SQLite and MySQL? I, at the time, I solved by changing DBUtils: Code: For i = 0 To cur.ColumnCount - 1 Dim ColName As String If DBType = DBMYSQL Then ColName = GetColumnLabel(cur, i) Else ColName = cur.GetColumnName(i) End If cols.Add(ColName) Next thanks
Erel B4X founder Staff member Licensed User Longtime User Feb 10, 2015 #6 Have you tested GetColumnLabel with SQLite? What does it return?