ODBC to SQL server 2005 crashes livecode
Posted: Thu Feb 23, 2012 12:11 am
Hi, I've got an ordering app that fills in an order form (customer & product details) from a database.
Users can specify which columns and tables they want to see & how they're to be sorted and search them. And click on a row to do more.
Anyway, it's been working well with MS access.
Now I need it to work with MS SQL (I've been told there are 3 clients 'ready to go' --meaning I really really need this to work & can't just keep using Access).
I've put the company database into SQL express 2005 for test purposes.
At first everything looked peachy, the app connected, the database tables appeared, but then the trouble started...
It seems that single SQL queries work fine.
A repeat loop with 5 or so iterations usually worked, i.e.
SELECT [column_name] FROM [table] ORDER BY [ID]
(then put the result into a field).
Occasionally it would generate a revDB error "Connection is busy with results for another command"
I tried to fix this by explicitly opening and closing the database for each and every sql query thus (for example):
repeat for each line colName in colsToViewList
dbConnect -- connects to db
put revDataFromQuery(,,dataBaseID,tSQLQuery) into fld fldName
revCloseDatabase dataBaseID
end repeat
This made the appearance of the "Connection is busy with results for another command" error rare but made the app noticeably slower.
But there's another problem.
Livecode simply crashes.
Back to the desktop, all gone.
This happens most commonly when the number of loops is around 10 or more. There are 30+ columns in the customer database. Users can choose to display them all. Sometimes (rarely) the app will survive a thirty iteration loop, almost always it crashes. Sometimes it seems to crash for no discernible reason.
None of this happens with ms access.
I'm using the SQL native client odbc driver.
I've looked into MARS (Multiple Active Result Sets) as this feature (disabled by default) is associated with the "Connection is busy" error. However I can't find any way to enable MARS --it requires a parameter added to the connection string along the lines of:
SQL Native Client ODBC Driver
Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;
Uid=myUsername;Pwd=myPassword;MARS_Connection=yes;
And I haven't been able to reconcile this with liveCode's:
revOpenDatabase("odbc",host[:port], databaseName, [userName],[password],[cursorType])
It's a memory issue? (Even though I open & close the database for each iteration). I haven't tried playing with the SQL Express memory settings (because I really don't know what I'm doing).
Any comments or suggestions very much appreciated...
Steve
Users can specify which columns and tables they want to see & how they're to be sorted and search them. And click on a row to do more.
Anyway, it's been working well with MS access.
Now I need it to work with MS SQL (I've been told there are 3 clients 'ready to go' --meaning I really really need this to work & can't just keep using Access).
I've put the company database into SQL express 2005 for test purposes.
At first everything looked peachy, the app connected, the database tables appeared, but then the trouble started...
It seems that single SQL queries work fine.
A repeat loop with 5 or so iterations usually worked, i.e.
SELECT [column_name] FROM [table] ORDER BY [ID]
(then put the result into a field).
Occasionally it would generate a revDB error "Connection is busy with results for another command"
I tried to fix this by explicitly opening and closing the database for each and every sql query thus (for example):
repeat for each line colName in colsToViewList
dbConnect -- connects to db
put revDataFromQuery(,,dataBaseID,tSQLQuery) into fld fldName
revCloseDatabase dataBaseID
end repeat
This made the appearance of the "Connection is busy with results for another command" error rare but made the app noticeably slower.
But there's another problem.
Livecode simply crashes.
Back to the desktop, all gone.
This happens most commonly when the number of loops is around 10 or more. There are 30+ columns in the customer database. Users can choose to display them all. Sometimes (rarely) the app will survive a thirty iteration loop, almost always it crashes. Sometimes it seems to crash for no discernible reason.
None of this happens with ms access.
I'm using the SQL native client odbc driver.
I've looked into MARS (Multiple Active Result Sets) as this feature (disabled by default) is associated with the "Connection is busy" error. However I can't find any way to enable MARS --it requires a parameter added to the connection string along the lines of:
SQL Native Client ODBC Driver
Driver={SQL Native Client};Server=myServerAddress;Database=myDataBase;
Uid=myUsername;Pwd=myPassword;MARS_Connection=yes;
And I haven't been able to reconcile this with liveCode's:
revOpenDatabase("odbc",host[:port], databaseName, [userName],[password],[cursorType])
It's a memory issue? (Even though I open & close the database for each iteration). I haven't tried playing with the SQL Express memory settings (because I really don't know what I'm doing).
Any comments or suggestions very much appreciated...
Steve