Background
I'm using Zinc 3 as a wrapper around a Flash 9 / ActionScript 3 application for a touch-screen kiosk that requires database and comport access.Problem
The Zinc application crashes when calling mdm.Database.ADO.getData() to obtain the results of a query (either SELECT or stored procedure) executed by mdm.Database.ADO.select() IF the query produces an empty result set. I'm connecting to a MS SQL Server 2005 database, but this issue probably happens with any ADO connection.Example
mdm.Database.ADO.select(sql); //if this results in 0 records...
if (mdm.Database.ADO.error())
throw("handle error here");
else
arr = mdm.Database.ADO.getData(); //crashes here
if (mdm.Database.ADO.error())
throw("handle error here");
else
arr = mdm.Database.ADO.getData(); //crashes here
Solution
The undocumented but simple way to prevent the crash is: prior to calling getData(), you must first check ensure that getRecordCount() is not zero.Example
mdm.Database.ADO.select(sql);
if (mdm.Database.ADO.error())
throw("handle error here");
else if (mdm.Database.ADO.getRecordCount() == 0)
arr = [];
else
arr = mdm.Database.ADO.getData();
if (mdm.Database.ADO.error())
throw("handle error here");
else if (mdm.Database.ADO.getRecordCount() == 0)
arr = [];
else
arr = mdm.Database.ADO.getData();
hello, i have problem with connecting zinc 3 to MS SQL EXPRESS database. Can you post a little example how to connect zinc and sql server?
ReplyDelete