Only one query per OpenDatabase?
Posted: Sat Mar 25, 2023 8:49 pm
I was thinking of connecting to ms sql database using standard pb library and ODBC. But I'm confused, the documentation implies you can only have one active query going against an "open" database. Meaning if I want to have three query results available at the same time, I would have to call OpenDatabase three times? I'm used to ...
a) gettting a connection to db,
b) using that single connection to return multiple queries, one after another or simultaneously
c) close my queries when done, and
d) finally, close database connection when done.
But PB docs show:
a) OpenDatabase returns a database ID
b) use that db ID in DatabaseQuery call to execute a Select statement
c) when done with select, call FinishDatabaseQuery to "close" query
...but FinishDatabaseQuery expects a db ID. There is no "query id". DatabaseQuery doesn't return a handle to a specific query, just a true/false result.
Well, that implies I need three different db ID's if I want three queries open at the same time. So I'd have to call OpenDatabase three times. Is it really opening three separate connections, or is it smart enough behind the scenes to use the same ODBC connection for all queries?
Thanks
a) gettting a connection to db,
b) using that single connection to return multiple queries, one after another or simultaneously
c) close my queries when done, and
d) finally, close database connection when done.
But PB docs show:
a) OpenDatabase returns a database ID
b) use that db ID in DatabaseQuery call to execute a Select statement
c) when done with select, call FinishDatabaseQuery to "close" query
...but FinishDatabaseQuery expects a db ID. There is no "query id". DatabaseQuery doesn't return a handle to a specific query, just a true/false result.
Well, that implies I need three different db ID's if I want three queries open at the same time. So I'd have to call OpenDatabase three times. Is it really opening three separate connections, or is it smart enough behind the scenes to use the same ODBC connection for all queries?
Thanks