Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2026-03

Error "Cannot open a non-select statement" when activating a TSQLQuery from the object inspector

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luca Olivetti

Hello

I'm trying to add some fields to a TSQLQuery, but when I try to activate it from the object inspector I get the error "Cannot open a non-select statement".
In fact the query is an "exec" to execute a stored procedure in an ms sql server.
The query works fine at runtime and I'm quite sure that I added fields to it by opening it at design time (though my memory could be failing me). The last time I added a field to this query was 9 months ago, so I was either using lazarus 4.0 or lazarus 3.8, however I tried both (as well as 4.2 and 4.4) but I still get the same error.
Is it just a PEBKAC?

Luca Olivetti Tel. +34 935883004 Ext. 3010 https://wetron.es https://wecobots.com

Reply by email

Michael Van Canneyt
to Luca Olivetti
Luca Olivetti wrote 13 lines
Hello I'm trying to add some fields to a TSQLQuery, but when I try to activate it from the object inspector I get the error "Cannot open a non-select statement". In fact the query is an "exec" to execute a stored procedure in an ms sql server. The query works fine at runtime and I'm quite sure that I added fields to it by opening it at design time (though my memory could be failing me). The last time I added a field to this query was 9 months ago, so I was either using lazarus 4.0 or lazarus 3.8, however I tried both (as well as 4.2 and 4.4) but I still get the same error. Is it just a PEBKAC?

As far as I know, 3.8 up to 4.4 all use the same sqldb from FPC 3.2.2. So either PEBKAC or issue in Lazarus itself.

Michael.

Reply by email

Luca Olivetti
to Michael Van Canneyt

El 11/3/26 a les 14:29, Michael Van Canneyt via lazarus ha escrit:

Show quoted text 21 lines
On Wed, 11 Mar 2026, Luca Olivetti via lazarus wrote: > Hello > > I'm trying to add some fields to a TSQLQuery, but when I try to > activate it from the object inspector I get the error "Cannot open a > non-select statement". > In fact the query is an "exec" to execute a stored procedure in an ms > sql server. > The query works fine at runtime and I'm quite sure that I added fields > to it by opening it at design time (though my memory could be failing > me). > The last time I added a field to this query was 9 months ago, so I was > either using lazarus 4.0 or lazarus 3.8, however I tried both (as well > as 4.2 and 4.4) but I still get the same error. > Is it just a PEBKAC? As far as I know, 3.8 up to 4.4 all use the same sqldb from FPC 3.2.2. So either PEBKAC or issue in Lazarus itself.

Thank you.
That's what I thought too and, yes, it was a PEBKAC, but not my chair, at least not exclusively :-D
I'm not in charge of the sql server, I think they changed something on their side: the stored procedure takes a parameter, at runtime I give it the correct value, while in the object inspector it was empty. When I last opened it from the object inspector, even with NULL it returned no records but the correct set of fields, but now it doesn't (and it doesn't complain).

Bye

Luca Olivetti Tel. +34 935883004 Ext. 3010 https://wetron.es https://wecobots.com

Reply by email