and i cant use 2 or plus rowset in the same portion of code tha uses the same db connection ???
While executing multiple statements simultaneously over a single connection does spare you the (“time-consuming”) handshake between the client and the server, processing each statement via its own dedicated connection can be faster and more secure.
Incidentally, multi-statements potentially leave the door wide open for SQL injection vulnerabilities.
Furthermore, if just one of your multi-statements encounters an error, it blocks all subsequent statements.
I believe it is advisable to use a separate connection for each individual statement.
On a different note: may I ask why you are executing the exact same query twice in immediate succession?
I would assume that executing the query just once—“caching” the collected data in objects, and then processing it further—would be faster than working through two simultaneous RowSets?
could you set r = nil before using r1?
This is really strange that you get these errors so often.
no no, i have try r=nil and work fine
but if i wont use multiple (N) rowset in same portion code, i must open (N) db connections and i can’t use the same db connection.
then , i must close (N) db connection to relase db resources
its an example code for test MBD SQL plugin, it isent real code !
I like working with custom classes for specific objects—such as server connections.
If I wanted to implement your example in my own app, I would first create a database class (the Super of this class would be a SQLConnectionMBS class):
I would then use these as follows:
Var db1 As New Class_mySQL
Var db2 As New Class_mySQL
Try
db1.Connect
db2.Connect
Var f As FolderItem = New FolderItem( "C:\Program Files\MySQL\MySQL Server 5.7\lib\libmysql.dll" )
db1.SetFileOption SQLConnectionMBS.kOptionLibraryMySQL, f
Var r1 As RowSet = r1 = db1.SelectSQL( "Select * from allegati limit 100" )
Var r2 As RowSet = r2 = db2.SelectSQL( "Select * from allegati limit 100" )
Catch err As ...
// Error Handling
End Try
If you attempt something similar, does the server really crash immediately?
If so, something is wrong with the server. ![]()
Can you check if the database connects at all?
He receives an error message from the server, so a connection has been established. However, the server tells him that he cannot initiate the second query right now.
His example presumably lacks only a reference to dd.connect. ![]()
If i set r=nil. (Like Christian say)
The second r1 works fine
The error Is raised when multiple rowset point to the same db connection.
If you try to use plus rowset on same db connectuon with xojo mysql pluging, It works fine
Is not problem of db server
But, xojo mysql plugin introduce onother problem that random freezes webApp.
Please try:
// turn on auto cache
db.Option("AutoCache") = "true"
this caches the recordset locally. Does it now work for 2 RowSets?
With your code you created 2 new database connections and I know it works without needing to test it because the problem occurs when I create multiple rowsets that use the same MBS database connection.
this works !!!
Thank you Christian !
