gb.db2 Order by
Posted
#1
(In Topic #1437)
Regular

I have also the problem, when i have a combobox and i open the popup (in the combobox), select a entry and then i enter in the field a text, the keypress event is not working, until i put the focus to another control and then i go back. The same problem i have in the IDE, from time to time, i need to select again the module or class, otherwise the keyboard is not working. I have this issue on Ubuntu 24.04 and on Ubuntu 24.10 (x86_64 and arm64). Anyone a idea what is the problem?
Thanks
Posted
Guru


Regarding your "Click" problem, try Public Sub ComboBox1_Activate() not Public Sub ComboBox1_Click(). I think that will help you.
Posted
Regular

Posted
Regular

I have had no problems at all with db2,
b
Posted
Banned
But I often find i have typed something in a class/module but it did not appear because the editor was not focused and i have to click on the document to use the keyboard.
This happens sometimes after hitting the "run" button to test a program. (and possibly other IDE forms opening then closing)
It's simply (annoyingly) after a test run the editor does not regain focus and needs to be clicked.
It maybe a toolkit issue , try the IDE (and your program) with QT and see if it still happens.
env GB_GUI=gb.gui.qt gambas3
Posted
Regular

Code (gambas)
With gb.db works, but with gb.db2 not.
Posted
Regular

I have a combobox with there i search in a gridlist the data, with up and down i scroll the gridlist.
Code (gambas)
- ' Message(Key.Code)
- iindex = i
- i = GridList.Rows.Count - 1
- iIndex = mGridlist.FindIndexofText(cboSearch.Text)
- GridList.Scroll(0, GridList.Current.Y)
- 'Show Record
- GridSelected(GridList[GridList.Row, 0].Text)
- iindex = iindex - 1
- GridList.Row = iindex
- GridList.Scroll(0, GridList.Current.Y)
Posted
Guru


Andreas_K said
Hello, I am not an expert, but I am currently experimenting with an SQL database.
So far I have no problems with gb.db2
But I immediately notice something in your code.
You have not quoted correctly in db.Subst.
If you want to substitute a table name, you have to put it in square brackets.
See /doc/db-quoting - Gambas Documentation
"If a substitution pattern in enclosed with square brackets, then the argument is supposed to be a table name, and the Connection.Quote method is used to correctly quote the table name into the result string. "
so you have to write
Code
ssql = db.Subst("SELECT * FROM [&1]" & sWhere & "ORDER BY '&2' ", sTable, sField1)Try it out to see if this fixes the error.
Best regards
Poly
Posted
Expert


Just a best practice thing - I'd recommend NOT using the name 'sWHERE' as a variable as it's a SQL key word and it makes it somewhat confusing when you look at the statement.
Can you give me an example of what you would pass in sWhere please, as I can't quite make sense of your SQL statement.
I'm not an expert but I do write a lot of MySql / SQLite based applications in Gambas.
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Regular

Posted
Guru


Quincunxian said
Can you give me an example of what you would pass in sWhere please, as I can't quite make sense of your SQL statement.
I have simply taken Andreas' example and tried to quote correctly.
The sWhere doesn't make sense to me in this context either, but he wrote that this example worked for gb.db.
That's why I assumed that it could just be a problem with the quoting. As explained in my link to Wiki.
But it is not.
The following works for me with gb.db and gb.db.form but not with gb.db2 and gb.db2.form
So I can confirm the problem.
Posted
Enthusiast

Posted
Guru


grayghost4 said
Many thanks,
I I had to adapt your code a bit, but it doesn't work.
with gb.db2 I get: Typ missmatsch wanted DB, got String instead
with gd.db I get: not a function
I think there is a problem with gd.db2 or it works differently.
I get even with the simplest form that works normally under gd.db, with gd.db2:
rs = DB.Subst("SELECT * FROM [&1]", "Namen")
the following error.
No such table: 'Name'
But I have to check this again in a programme without IDE. Because I use a data browser to display it.
That's why the code looks exactly like this for me:
Code
DataSource1.Table = DB.Subst("SELECT * FROM [&1]", "Namen")Works perfectly with gd.db and gb.db.form but not with gb.db2 and gb.db2.form
Thank you very much for your attention.
Best regards
Poly
Posted
Enthusiast

edit … I see that does not work
Posted
Enthusiast

Posted
Guru


So it is definitely a different behaviour due to the new component.
It may be that my code is somehow badly built, I will test this again in a very simple database without an IDE.
So far I can't say that this is a bug or error.
I will test your code immediately
Thanks Poly
Posted
Enthusiast

Code (gambas)
- ' Gambas module file
- '' Module file to handle SQLite file
- '' SQLite file handeling subroutines
- '' writen by GrayGhost4 Marvin Clavey June 2022
- With $con
- .Type = "sqlite3" ' Defines the type of connection
- .Name = "data.SQL" ' database name is the name of the database file"
- sainfo.Add(RS[obj.Name])
- Return saInfo
- saInfo = saInfo.Reverse()
- ' Deleat one reccord from the table with an indexed coluem
Posted
Guru


It works as you said, but then of course the DB for the string has to be removed.
This is also how it works for me with gb.db2
Thank you very much.
But then it is a bug or not.
So the substitution with Db.Subst does not work.
That shouldn't be the case, should it?
Posted
Enthusiast

Quote(&3) ….
also I dont think you need the " " around the varable name… that is what Quote() does
Posted
Guru


/doc/db-quoting - Gambas Documentation
Of course it is nonsense that there are two asterisks ** , of course there is only one, which stands for all columns.
Therefore, I would now clearly say that it is a bug in the DB.Stubst function.
But it would be great if someone else could confirm this.
And I have to set the inverted commas in the quote functions, otherwise I get an error.
unknown identifier
Your code is brilliant. Thank you very much.
Posted
Enthusiast

Posted
Enthusiast

Posted
Regular

Code (gambas)
Order by works only without " ' " (Apostrophe) and db.subst put this evertime, so its not working.
https://gambaswiki.org/wiki/doc/db-quoting with this i get only error, table not found….
Sorry for the two questions in one post.
Posted
Regular

It is for quoting values in SQL clauses in a way that Gambas can submit properly quoted sql.
If you want to insert bare strings into your sql then you must do it in 2 (or more) steps. Using Subst for the bare strings and using DB.Subst for actual values.
hth
b
Posted
Guru


thatbruce said
Ah, the fundamental misunderstand I believe that you may have is that DB.Subst is like Subst. It's not, nor was it ever intended to be.
It is for quoting values in SQL clauses in a way that Gambas can submit properly quoted sql.
However, this does not explain why it is shown differently in the wiki and why it runs in gb.db but not with gb.db2
It may be that some people here are only interested in a certain code to make something work. Not for me. I thought we should all be interested in finding and reporting errors or misunderstandings in the wiki or bugs in the individual components.
So if
But if this works for you, then it may also be due to my system.
I am using Devuan , x11 and Gambas 3.20.2
Best regards Poly
1 guest and 0 members have just viewed this.

