LucaMs Expert Licensed User Longtime User Sep 7, 2015 #1 If you use ExecuteQuery2, field names returned by Cursor1.GetColumnName will be all "?" (as in the query). I would prefer to receive the real names of the fields, of course. Thank you Last edited: Sep 7, 2015
If you use ExecuteQuery2, field names returned by Cursor1.GetColumnName will be all "?" (as in the query). I would prefer to receive the real names of the fields, of course. Thank you
Erel B4X founder Staff member Licensed User Longtime User Sep 7, 2015 #2 It shouldn't happen. Can you upload a small example?
LucaMs Expert Licensed User Longtime User Sep 7, 2015 #3 Attached. Thank you Attachments ExecuteQuery2 Test.zip ExecuteQuery2 Test.zip 11.8 KB · Views: 330
LucaMs Expert Licensed User Longtime User Sep 7, 2015 #4 I forgot to write: Code: Copy For i = 0 To Cur.RowCount - 1 Cur.Position = i Log(Cur.GetString("Name")) Next Field "Name" will "not exist"; "?" and "?" will exist.
I forgot to write: Code: Copy For i = 0 To Cur.RowCount - 1 Cur.Position = i Log(Cur.GetString("Name")) Next Field "Name" will "not exist"; "?" and "?" will exist.
M Mahares Expert Licensed User Longtime User Sep 7, 2015 #5 @LucaMs You cannot parametize field names in the SQL statement like you have here as far as I know: Query = "SELECT ?, ? FROM tbl"
@LucaMs You cannot parametize field names in the SQL statement like you have here as far as I know: Query = "SELECT ?, ? FROM tbl"
LucaMs Expert Licensed User Longtime User Sep 7, 2015 #6 Mahares said: @LucaMs You cannot parametize field names in the SQL statement like you have here as far as I know: Query = "SELECT ?, ? FROM tbl" Click to expand... Why not? Each "?" will be correctly replaced, it works. Moreover, in some cases I may not know a priori the name of the fields to be selected. I don't know if ExecuteQuery2 is a B4A or Java command. If it is B4A, Erel can modify it.
Mahares said: @LucaMs You cannot parametize field names in the SQL statement like you have here as far as I know: Query = "SELECT ?, ? FROM tbl" Click to expand... Why not? Each "?" will be correctly replaced, it works. Moreover, in some cases I may not know a priori the name of the fields to be selected. I don't know if ExecuteQuery2 is a B4A or Java command. If it is B4A, Erel can modify it.
M Mahares Expert Licensed User Longtime User Sep 7, 2015 #7 LucaMs said: Why not? Each "?" will be correctly replaced, it works. Click to expand... I do not get an error with this statement either, but it does not mean it is correct, even though the field name is 'name' and not LucaMS: Cur = mDB.ExecQuery2(Query, Array As String("ID", "LucaMS")) Also, I can do this: Query = "SELECT ?, ?, 'Erel', 'Klaus' FROM tbl" and not get an error. See this link: http://stackoverflow.com/questions/...terize-the-table-name-in-a-prepared-statement
LucaMs said: Why not? Each "?" will be correctly replaced, it works. Click to expand... I do not get an error with this statement either, but it does not mean it is correct, even though the field name is 'name' and not LucaMS: Cur = mDB.ExecQuery2(Query, Array As String("ID", "LucaMS")) Also, I can do this: Query = "SELECT ?, ?, 'Erel', 'Klaus' FROM tbl" and not get an error. See this link: http://stackoverflow.com/questions/...terize-the-table-name-in-a-prepared-statement
Erel B4X founder Staff member Licensed User Longtime User Sep 7, 2015 #8 Mahares is correct. You cannot replace field names and table names with question marks. Parameterized queries is a feature of the SQL engine. It is not a simple string replacement.
Mahares is correct. You cannot replace field names and table names with question marks. Parameterized queries is a feature of the SQL engine. It is not a simple string replacement.