我在
SQL中编写了一个数据库生成脚本,并希望在我的
Adobe AIR应用程序中执行它:
Create Table tRole ( roleID integer Primary Key,roleName varchar(40) ); Create Table tFile ( fileID integer Primary Key,fileName varchar(50),fileDescription varchar(500),thumbnailID integer,fileFormatID integer,categoryID integer,isFavorite boolean,dateAdded date,globalAccessCount integer,lastAccessTime date,downloadComplete boolean,isNew boolean,isSpotlight boolean,duration varchar(30) ); Create Table tCategory ( categoryID integer Primary Key,categoryName varchar(50),parent_categoryID integer ); ...
我在Adobe AIR中使用以下方法执行此操作:
public static function RunsqlFromFile(fileName:String):void { var file:File = File.applicationDirectory.resolvePath(fileName); var stream:FileStream = new FileStream(); stream.open(file,FileMode.READ) var strsql:String = stream.readUTFBytes(stream.bytesAvailable); NonQuery(strsql); } public static function NonQuery(strsql:String):void { var sqlConnection:sqlConnection = new sqlConnection(); sqlConnection.open(File.applicationStorageDirectory.resolvePath(DBPATH); var sqlStatement:sqlStatement = new sqlStatement(); sqlStatement.text = strsql; sqlStatement.sqlConnection = sqlConnection; try { sqlStatement.execute(); } catch (error:sqlError) { Alert.show(error.toString()); } }
不会生成错误,但只存在tRole。它似乎只看第一个查询(直到分号 – 如果我删除它,查询失败)。有没有办法在一个语句中调用多个查询?