Re: [Flashcoders] Question AIR Sqlite api
Thanx Muzak, I will try your solution Muzak wrote: I think I had a similar error when one of the statements wasn't valid. In this case I'd think that one of the tables already exists (which ends the transaction) and when the next statement is exectuted it throws the error you see. Here's something I used: try { _sqlConnection.begin(); // // sql statements here // _sqlConnection.commit(); }catch(e:SQLError) { trace("- message; ", e.message); trace("- details: ", e.details); _sqlConnection.rollback(); } } When creating a table it is a good idea to check if the table already exists. 'CREATE TABLE IF NOT EXISTS ...' regards, Muzak - Original Message - From: "Jiri Heitlager" <[EMAIL PROTECTED]> To: "Flash Coders List" Sent: Friday, April 18, 2008 10:19 AM Subject: Re: [Flashcoders] Question AIR Sqlite api OK, I relplied a bit in a hurry and didnt make myself clear. That is stupid of me, and I am sorry. The situation is like so. I open a connection using OpenAsync. I have listeners listening to the Open event. When that is fired, I response with a method that creates 3 tables in one go, see code below. I keep getting an error, also shown below. If in the whole story I use open instead of openAsync, everything works perfect. I have now idea why that is?? Error: Error #3105: Operation is only allowed if a connection has an open transaction. at Error$/throwError() at flash.data::SQLConnection/commit() at classes.models::SQLProxy/createDatabase()[/Users/Jiri/Documents/_Flash/SmsApp/SmsApplication/src/classes/models/SQLProxy.as:128] Debug session terminated. private function createDatabase(e:Event):void { Sql_conn.addEventListener(SQLEvent.COMMIT , onDatabaseCreated); Sql_conn.begin(); var createTable:SQLStatement = new SQLStatement() createTable.sqlConnection = Sql_conn createTable.text = 'CREATE TABLE contacts (index_id INTEGER PRIMARY KEY , name TEXT , phone NUMBER )'; createTable.execute(); var createErrors:SQLStatement = new SQLStatement() createErrors.sqlConnection = Sql_conn createErrors.text = 'CREATE TABLE errors (index_id INTEGER PRIMARY KEY , error_id INTEGER , type TEXT )'; createErrors.execute(); var createArchive:SQLStatement = new SQLStatement() createArchive.sqlConnection = Sql_conn createArchive.text = 'CREATE TABLE sms_archive (index_id INTEGER PRIMARY KEY , sms TEXT , receiver NUMBER , sender NUMBER )'; createArchive.execute(); Sql_conn.commit(); } Muzak wrote: Then I'm not sure I understand what your problem is. You said it works when using openAsync().. The weird thing is that when I use openAsync instead of open, it does work? - Original Message - From: "Jiri Heitlager" <[EMAIL PROTECTED]> To: "Flash Coders List" Sent: Thursday, April 17, 2008 10:52 PM Subject: Re: [Flashcoders] Question AIR Sqlite api weird...I will have to look into that and see if there is a work around, because I would really like to work with openAsync. J. Muzak wrote: Because when adding listeners you are implying asynchronous mode. In other words, as soon as you add listeners, you have to use openAsync(). I've found the use of synchronous mode to be alot easier. regards, Muzak ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Question AIR Sqlite api
I think I had a similar error when one of the statements wasn't valid. In this case I'd think that one of the tables already exists (which ends the transaction) and when the next statement is exectuted it throws the error you see. Here's something I used: try { _sqlConnection.begin(); // // sql statements here // _sqlConnection.commit(); }catch(e:SQLError) { trace("- message; ", e.message); trace("- details: ", e.details); _sqlConnection.rollback(); } } When creating a table it is a good idea to check if the table already exists. 'CREATE TABLE IF NOT EXISTS ...' regards, Muzak - Original Message - From: "Jiri Heitlager" <[EMAIL PROTECTED]> To: "Flash Coders List" Sent: Friday, April 18, 2008 10:19 AM Subject: Re: [Flashcoders] Question AIR Sqlite api OK, I relplied a bit in a hurry and didnt make myself clear. That is stupid of me, and I am sorry. The situation is like so. I open a connection using OpenAsync. I have listeners listening to the Open event. When that is fired, I response with a method that creates 3 tables in one go, see code below. I keep getting an error, also shown below. If in the whole story I use open instead of openAsync, everything works perfect. I have now idea why that is?? Error: Error #3105: Operation is only allowed if a connection has an open transaction. at Error$/throwError() at flash.data::SQLConnection/commit() at classes.models::SQLProxy/createDatabase()[/Users/Jiri/Documents/_Flash/SmsApp/SmsApplication/src/classes/models/SQLProxy.as:128] Debug session terminated. private function createDatabase(e:Event):void { Sql_conn.addEventListener(SQLEvent.COMMIT , onDatabaseCreated); Sql_conn.begin(); var createTable:SQLStatement = new SQLStatement() createTable.sqlConnection = Sql_conn createTable.text = 'CREATE TABLE contacts (index_id INTEGER PRIMARY KEY , name TEXT , phone NUMBER )'; createTable.execute(); var createErrors:SQLStatement = new SQLStatement() createErrors.sqlConnection = Sql_conn createErrors.text = 'CREATE TABLE errors (index_id INTEGER PRIMARY KEY , error_id INTEGER , type TEXT )'; createErrors.execute(); var createArchive:SQLStatement = new SQLStatement() createArchive.sqlConnection = Sql_conn createArchive.text = 'CREATE TABLE sms_archive (index_id INTEGER PRIMARY KEY , sms TEXT , receiver NUMBER , sender NUMBER )'; createArchive.execute(); Sql_conn.commit(); } Muzak wrote: Then I'm not sure I understand what your problem is. You said it works when using openAsync().. The weird thing is that when I use openAsync instead of open, it does work? - Original Message - From: "Jiri Heitlager" <[EMAIL PROTECTED]> To: "Flash Coders List" Sent: Thursday, April 17, 2008 10:52 PM Subject: Re: [Flashcoders] Question AIR Sqlite api weird...I will have to look into that and see if there is a work around, because I would really like to work with openAsync. J. Muzak wrote: Because when adding listeners you are implying asynchronous mode. In other words, as soon as you add listeners, you have to use openAsync(). I've found the use of synchronous mode to be alot easier. regards, Muzak ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Question AIR Sqlite api
OK, I relplied a bit in a hurry and didnt make myself clear. That is stupid of me, and I am sorry. The situation is like so. I open a connection using OpenAsync. I have listeners listening to the Open event. When that is fired, I response with a method that creates 3 tables in one go, see code below. I keep getting an error, also shown below. If in the whole story I use open instead of openAsync, everything works perfect. I have now idea why that is?? Error: Error #3105: Operation is only allowed if a connection has an open transaction. at Error$/throwError() at flash.data::SQLConnection/commit() at classes.models::SQLProxy/createDatabase()[/Users/Jiri/Documents/_Flash/SmsApp/SmsApplication/src/classes/models/SQLProxy.as:128] Debug session terminated. private function createDatabase(e:Event):void { Sql_conn.addEventListener(SQLEvent.COMMIT , onDatabaseCreated); Sql_conn.begin(); var createTable:SQLStatement = new SQLStatement() createTable.sqlConnection = Sql_conn createTable.text = 'CREATE TABLE contacts (index_id INTEGER PRIMARY KEY , name TEXT , phone NUMBER )'; createTable.execute(); var createErrors:SQLStatement = new SQLStatement() createErrors.sqlConnection = Sql_conn createErrors.text = 'CREATE TABLE errors (index_id INTEGER PRIMARY KEY , error_id INTEGER , type TEXT )'; createErrors.execute(); var createArchive:SQLStatement = new SQLStatement() createArchive.sqlConnection = Sql_conn createArchive.text = 'CREATE TABLE sms_archive (index_id INTEGER PRIMARY KEY , sms TEXT , receiver NUMBER , sender NUMBER )'; createArchive.execute(); Sql_conn.commit(); } Muzak wrote: Then I'm not sure I understand what your problem is. You said it works when using openAsync().. The weird thing is that when I use openAsync instead of open, it does work? - Original Message - From: "Jiri Heitlager" <[EMAIL PROTECTED]> To: "Flash Coders List" Sent: Thursday, April 17, 2008 10:52 PM Subject: Re: [Flashcoders] Question AIR Sqlite api weird...I will have to look into that and see if there is a work around, because I would really like to work with openAsync. J. Muzak wrote: Because when adding listeners you are implying asynchronous mode. In other words, as soon as you add listeners, you have to use openAsync(). I've found the use of synchronous mode to be alot easier. regards, Muzak ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Question AIR Sqlite api
Then I'm not sure I understand what your problem is. You said it works when using openAsync().. The weird thing is that when I use openAsync instead of open, it does work? - Original Message - From: "Jiri Heitlager" <[EMAIL PROTECTED]> To: "Flash Coders List" Sent: Thursday, April 17, 2008 10:52 PM Subject: Re: [Flashcoders] Question AIR Sqlite api weird...I will have to look into that and see if there is a work around, because I would really like to work with openAsync. J. Muzak wrote: Because when adding listeners you are implying asynchronous mode. In other words, as soon as you add listeners, you have to use openAsync(). I've found the use of synchronous mode to be alot easier. regards, Muzak ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Question AIR Sqlite api
weird...I will have to look into that and see if there is a work around, because I would really like to work with openAsync. J. Muzak wrote: Because when adding listeners you are implying asynchronous mode. In other words, as soon as you add listeners, you have to use openAsync(). I've found the use of synchronous mode to be alot easier. regards, Muzak - Original Message - From: "Jiri Heitlager" <[EMAIL PROTECTED]> To: "Flash Coders List" Sent: Wednesday, April 16, 2008 5:02 PM Subject: [Flashcoders] Question AIR Sqlite api I have a question about SQLite and AIR. Does anybody know why I get this error, becuase the connection is open? I put the code below. The weird thing is that when I use openAsync instead of open, it does work? Error: Error #3105: Operation is only allowed if a connection has an open transaction. at Error$/throwError() at flash.data::SQLConnection/commit() at classes.models::SQLProxy/createDatabase()[/Users/Jiri/Documents/_Flash/SmsApp/SmsApplication/src/classes/models/SQLProxy.as:128] Debug session terminated. protected function build():void { Sql_db = File.applicationDirectory.resolvePath('TESTER.db') var exists:Boolean = Sql_db.exists if ( exists ) { Sql_conn.addEventListener(SQLEvent.OPEN , onDBStatementOpenResult); }else { Sql_conn.addEventListener(SQLEvent.OPEN , createDatabase); } Sql_conn.openAsync( Sql_db ) } private function createDatabase(e:Event):void { Sql_conn.addEventListener(SQLEvent.COMMIT , onDatabaseCreated); Sql_conn.begin(); var createTable:SQLStatement = new SQLStatement() createTable.sqlConnection = Sql_conn createTable.text = 'CREATE TABLE contacts (index_id INTEGER PRIMARY KEY , name TEXT , phone NUMBER )'; createTable.execute(); var createErrors:SQLStatement = new SQLStatement() createErrors.sqlConnection = Sql_conn createErrors.text = 'CREATE TABLE errors (index_id INTEGER PRIMARY KEY , error_id INTEGER , type TEXT )'; createErrors.execute(); var createArchive:SQLStatement = new SQLStatement() createArchive.sqlConnection = Sql_conn createArchive.text = 'CREATE TABLE sms_archive (index_id INTEGER PRIMARY KEY , sms TEXT , receiver NUMBER , sender NUMBER )'; createArchive.execute(); Sql_conn.commit(); } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Question AIR Sqlite api
Because when adding listeners you are implying asynchronous mode. In other words, as soon as you add listeners, you have to use openAsync(). I've found the use of synchronous mode to be alot easier. regards, Muzak - Original Message - From: "Jiri Heitlager" <[EMAIL PROTECTED]> To: "Flash Coders List" Sent: Wednesday, April 16, 2008 5:02 PM Subject: [Flashcoders] Question AIR Sqlite api I have a question about SQLite and AIR. Does anybody know why I get this error, becuase the connection is open? I put the code below. The weird thing is that when I use openAsync instead of open, it does work? Error: Error #3105: Operation is only allowed if a connection has an open transaction. at Error$/throwError() at flash.data::SQLConnection/commit() at classes.models::SQLProxy/createDatabase()[/Users/Jiri/Documents/_Flash/SmsApp/SmsApplication/src/classes/models/SQLProxy.as:128] Debug session terminated. protected function build():void { Sql_db = File.applicationDirectory.resolvePath('TESTER.db') var exists:Boolean = Sql_db.exists if ( exists ) { Sql_conn.addEventListener(SQLEvent.OPEN , onDBStatementOpenResult); }else { Sql_conn.addEventListener(SQLEvent.OPEN , createDatabase); } Sql_conn.openAsync( Sql_db ) } private function createDatabase(e:Event):void { Sql_conn.addEventListener(SQLEvent.COMMIT , onDatabaseCreated); Sql_conn.begin(); var createTable:SQLStatement = new SQLStatement() createTable.sqlConnection = Sql_conn createTable.text = 'CREATE TABLE contacts (index_id INTEGER PRIMARY KEY , name TEXT , phone NUMBER )'; createTable.execute(); var createErrors:SQLStatement = new SQLStatement() createErrors.sqlConnection = Sql_conn createErrors.text = 'CREATE TABLE errors (index_id INTEGER PRIMARY KEY , error_id INTEGER , type TEXT )'; createErrors.execute(); var createArchive:SQLStatement = new SQLStatement() createArchive.sqlConnection = Sql_conn createArchive.text = 'CREATE TABLE sms_archive (index_id INTEGER PRIMARY KEY , sms TEXT , receiver NUMBER , sender NUMBER )'; createArchive.execute(); Sql_conn.commit(); } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Question AIR Sqlite api
Morten, i just burst my own bubble. It appears not to be working after all. It seems the line Sql_conn.openAsync( Sql_db ) in the build() method is the problem, becuase when I change it to Sql_conn.open( Sql_db ) everything works fine. Do you have any other suggestions? Jiri Morten Barklund wrote: Hi Jiri, I believe it is due to the default lock type. The default lock type (DEFERRED) description says: * SQLTransactionLockType.DEFERRED indicates that a lock is not acquired until the first read or write operation. And since a "CREATE" is technically neither a data read or data write, but a scheme altering method, it could be the cause. Try changing the lock method be explicitly specifying EXCLUSIVE as a parameter to begin(): Sql_conn.begin(SQLTransactionLockType.EXCLUSIVE); Hope that helps, Regards, Morten Barklund -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jiri Heitlager Sent: Wednesday, April 16, 2008 5:02 PM To: Flash Coders List Subject: [Flashcoders] Question AIR Sqlite api I have a question about SQLite and AIR. Does anybody know why I get this error, becuase the connection is open? I put the code below. The weird thing is that when I use openAsync instead of open, it does work? Error: Error #3105: Operation is only allowed if a connection has an open transaction. at Error$/throwError() at flash.data::SQLConnection/commit() at classes.models::SQLProxy/createDatabase()[/Users/Jiri/Documents/_Flash/SmsApp/SmsApplication/src/classes/models/SQLProxy.as:128] Debug session terminated. protected function build():void { Sql_db = File.applicationDirectory.resolvePath('TESTER.db') var exists:Boolean = Sql_db.exists if ( exists ) { Sql_conn.addEventListener(SQLEvent.OPEN , onDBStatementOpenResult); }else { Sql_conn.addEventListener(SQLEvent.OPEN , createDatabase); } Sql_conn.openAsync( Sql_db ) } private function createDatabase(e:Event):void { Sql_conn.addEventListener(SQLEvent.COMMIT , onDatabaseCreated); Sql_conn.begin(); var createTable:SQLStatement = new SQLStatement() createTable.sqlConnection = Sql_conn createTable.text = 'CREATE TABLE contacts (index_id INTEGER PRIMARY KEY , name TEXT , phone NUMBER )'; createTable.execute(); var createErrors:SQLStatement = new SQLStatement() createErrors.sqlConnection = Sql_conn createErrors.text = 'CREATE TABLE errors (index_id INTEGER PRIMARY KEY , error_id INTEGER , type TEXT )'; createErrors.execute(); var createArchive:SQLStatement = new SQLStatement() createArchive.sqlConnection = Sql_conn createArchive.text = 'CREATE TABLE sms_archive (index_id INTEGER PRIMARY KEY , sms TEXT , receiver NUMBER , sender NUMBER )'; createArchive.execute(); Sql_conn.commit(); } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Question AIR Sqlite api
Perfect that was it. Thank you Morten. Jiri Morten Barklund wrote: Hi Jiri, I believe it is due to the default lock type. The default lock type (DEFERRED) description says: * SQLTransactionLockType.DEFERRED indicates that a lock is not acquired until the first read or write operation. And since a "CREATE" is technically neither a data read or data write, but a scheme altering method, it could be the cause. Try changing the lock method be explicitly specifying EXCLUSIVE as a parameter to begin(): Sql_conn.begin(SQLTransactionLockType.EXCLUSIVE); Hope that helps, Regards, Morten Barklund -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jiri Heitlager Sent: Wednesday, April 16, 2008 5:02 PM To: Flash Coders List Subject: [Flashcoders] Question AIR Sqlite api I have a question about SQLite and AIR. Does anybody know why I get this error, becuase the connection is open? I put the code below. The weird thing is that when I use openAsync instead of open, it does work? Error: Error #3105: Operation is only allowed if a connection has an open transaction. at Error$/throwError() at flash.data::SQLConnection/commit() at classes.models::SQLProxy/createDatabase()[/Users/Jiri/Documents/_Flash/SmsApp/SmsApplication/src/classes/models/SQLProxy.as:128] Debug session terminated. protected function build():void { Sql_db = File.applicationDirectory.resolvePath('TESTER.db') var exists:Boolean = Sql_db.exists if ( exists ) { Sql_conn.addEventListener(SQLEvent.OPEN , onDBStatementOpenResult); }else { Sql_conn.addEventListener(SQLEvent.OPEN , createDatabase); } Sql_conn.openAsync( Sql_db ) } private function createDatabase(e:Event):void { Sql_conn.addEventListener(SQLEvent.COMMIT , onDatabaseCreated); Sql_conn.begin(); var createTable:SQLStatement = new SQLStatement() createTable.sqlConnection = Sql_conn createTable.text = 'CREATE TABLE contacts (index_id INTEGER PRIMARY KEY , name TEXT , phone NUMBER )'; createTable.execute(); var createErrors:SQLStatement = new SQLStatement() createErrors.sqlConnection = Sql_conn createErrors.text = 'CREATE TABLE errors (index_id INTEGER PRIMARY KEY , error_id INTEGER , type TEXT )'; createErrors.execute(); var createArchive:SQLStatement = new SQLStatement() createArchive.sqlConnection = Sql_conn createArchive.text = 'CREATE TABLE sms_archive (index_id INTEGER PRIMARY KEY , sms TEXT , receiver NUMBER , sender NUMBER )'; createArchive.execute(); Sql_conn.commit(); } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Question AIR Sqlite api
Hi Jiri, I believe it is due to the default lock type. The default lock type (DEFERRED) description says: * SQLTransactionLockType.DEFERRED indicates that a lock is not acquired until the first read or write operation. And since a "CREATE" is technically neither a data read or data write, but a scheme altering method, it could be the cause. Try changing the lock method be explicitly specifying EXCLUSIVE as a parameter to begin(): Sql_conn.begin(SQLTransactionLockType.EXCLUSIVE); Hope that helps, Regards, Morten Barklund -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jiri Heitlager Sent: Wednesday, April 16, 2008 5:02 PM To: Flash Coders List Subject: [Flashcoders] Question AIR Sqlite api I have a question about SQLite and AIR. Does anybody know why I get this error, becuase the connection is open? I put the code below. The weird thing is that when I use openAsync instead of open, it does work? Error: Error #3105: Operation is only allowed if a connection has an open transaction. at Error$/throwError() at flash.data::SQLConnection/commit() at classes.models::SQLProxy/createDatabase()[/Users/Jiri/Documents/_Flash/SmsApp/SmsApplication/src/classes/models/SQLProxy.as:128] Debug session terminated. protected function build():void { Sql_db = File.applicationDirectory.resolvePath('TESTER.db') var exists:Boolean = Sql_db.exists if ( exists ) { Sql_conn.addEventListener(SQLEvent.OPEN , onDBStatementOpenResult); }else { Sql_conn.addEventListener(SQLEvent.OPEN , createDatabase); } Sql_conn.openAsync( Sql_db ) } private function createDatabase(e:Event):void { Sql_conn.addEventListener(SQLEvent.COMMIT , onDatabaseCreated); Sql_conn.begin(); var createTable:SQLStatement = new SQLStatement() createTable.sqlConnection = Sql_conn createTable.text = 'CREATE TABLE contacts (index_id INTEGER PRIMARY KEY , name TEXT , phone NUMBER )'; createTable.execute(); var createErrors:SQLStatement = new SQLStatement() createErrors.sqlConnection = Sql_conn createErrors.text = 'CREATE TABLE errors (index_id INTEGER PRIMARY KEY , error_id INTEGER , type TEXT )'; createErrors.execute(); var createArchive:SQLStatement = new SQLStatement() createArchive.sqlConnection = Sql_conn createArchive.text = 'CREATE TABLE sms_archive (index_id INTEGER PRIMARY KEY , sms TEXT , receiver NUMBER , sender NUMBER )'; createArchive.execute(); Sql_conn.commit(); } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Question AIR Sqlite api
I have a question about SQLite and AIR. Does anybody know why I get this error, becuase the connection is open? I put the code below. The weird thing is that when I use openAsync instead of open, it does work? Error: Error #3105: Operation is only allowed if a connection has an open transaction. at Error$/throwError() at flash.data::SQLConnection/commit() at classes.models::SQLProxy/createDatabase()[/Users/Jiri/Documents/_Flash/SmsApp/SmsApplication/src/classes/models/SQLProxy.as:128] Debug session terminated. protected function build():void { Sql_db = File.applicationDirectory.resolvePath('TESTER.db') var exists:Boolean = Sql_db.exists if ( exists ) { Sql_conn.addEventListener(SQLEvent.OPEN , onDBStatementOpenResult); }else { Sql_conn.addEventListener(SQLEvent.OPEN , createDatabase); } Sql_conn.openAsync( Sql_db ) } private function createDatabase(e:Event):void { Sql_conn.addEventListener(SQLEvent.COMMIT , onDatabaseCreated); Sql_conn.begin(); var createTable:SQLStatement = new SQLStatement() createTable.sqlConnection = Sql_conn createTable.text = 'CREATE TABLE contacts (index_id INTEGER PRIMARY KEY , name TEXT , phone NUMBER )'; createTable.execute(); var createErrors:SQLStatement = new SQLStatement() createErrors.sqlConnection = Sql_conn createErrors.text = 'CREATE TABLE errors (index_id INTEGER PRIMARY KEY , error_id INTEGER , type TEXT )'; createErrors.execute(); var createArchive:SQLStatement = new SQLStatement() createArchive.sqlConnection = Sql_conn createArchive.text = 'CREATE TABLE sms_archive (index_id INTEGER PRIMARY KEY , sms TEXT , receiver NUMBER , sender NUMBER )'; createArchive.execute(); Sql_conn.commit(); } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders