Can't reconnect

Mark Schonewille m.schonewille at economy-x-talk.com
Mon Oct 14 18:39:33 CDT 2013


Hi,

Now I have a complete script for testing. I wrote it in such a way that 
it will make debugging a larger project much easier for me. It opens a 
connection, opens a database, does a simple query, closes the 
database(s), and disconnects.

The problem is that despite closing the databases and disconnecting, I 
still can't connect more than 5 times. I should be able to connect more 
than 5 times if I close old connections before making new ones. Whenever 
I try to connect for the 6th time, I have to wait an eternity until the 
error 0x82501 appears.

Why can't I connect more than 5 times, despite closing all connections 
first?

My script follows here. You need a stack with a button for the script 
and a field to display the log.

// keep local variables in memory
local lDatabaseConnection,lDatabase

// do the test
on mouseUp
    put empty into fld 1 // log field
    initValentina
    createDatabase
    query
    closeAllDatabases
    closeConnection
end mouseUp

// standard stuff, returns nothing in log
on initValentina
    log valentina_initClient() //(19*1024*1024)
    log valentina_debugLevel("kLogErrors")
end initValentina

// more standard stuff
on createDatabase
    put vConnection_Constructor("localhost","sa","sa",15432) into 
lDatabaseConnection
    log lDatabaseConnection
    put vDatabase_Constructor(lDatabaseConnection) into lDatabase
    log lDatabase
    log vDatabase_Open(lDatabase,"myDatabase.vdb")
    log vDatabase_DateFormat(lDatabase,"kYMD")
    log vDatabase_DateSep(lDatabase,"-")
end createDatabase

// obvious stuff
on query
    log dataFromTable(lDatabase,"mytable","myfield")
end query

// used by the query handler, not important
function dataFromTable theDatabaseID,theTable,theField
    put vDatabase_table(theDatabaseID,theTable) into myTableID
    put vTable_field(myTableID,theField) into myFieldID
    put vField_Value(myFieldID) into myData
    return myData
end dataFromTable

// closing all dtabases, important stuff
on closeAllDatabases
    put valentina_databasecount() into myDatabaseCount
    repeat with myDatabaseNr = 1 to myDatabaseCount
       put Valentina_Database(myDatabaseNr) into myDatabaseID
       put myDatabaseID & cr after fld 1
       if "ERROR" is not in myDatabaseID then
          if "ERROR" is not in vDatabase_Close(myDatabaseID) then
             put vDatabase_Destructor(myDatabaseID) into myDatabaseID
             put myDatabaseID & cr after fld 1 // 0
          else
             beep
             answer error "Can't close database."
          end if
       else
          beep
          answer error "Can't get a reference to the database."
       end if
    end repeat
end closeAllDatabases

// obvious
on closeConnection
    log valentina_shutdown(lDatabaseConnection)
end closeConnection

on log theData
    put theData & cr after fld 1
end log

Did I forget something in my script or is it a bug in Valentina?

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Use Color Converter to convert CMYK, RGB, RAL, XYZ, H.Lab and other 
colour spaces. http://www.color-converter.com

Buy my new book "Programming LiveCode for the Real Beginner" 
http://qery.us/3fi

Fill out this survey please
http://livecodebeginner.economy-x-talk.com/survey/


More information about the Valentina mailing list