|
本帖最后由 makuijun 于 2010-8-31 06:50 编辑
我在做AIR程序连接本地数据库的时候老是出现一个问题:
import mx.controls.Alert;
import flash.data.SQLConnection;
import flash.data.SQLStatement;
import flash.events.SQLErrorEvent;
import flash.events.SQLEvent;
private var conn:SQLConnection=new SQLConnection();
private var stmt:SQLStatement=new SQLStatement();
private var filedb:File=File.applicationStorageDirectory.resolvePath("School.db");
private function initApp():void{
conn.addEventListener(SQLEvent.OPEN,createTable);
conn.addEventListener(SQLErrorEvent.ERROR,error);
conn.open(filedb);
}
private function createTable():void{
stmt.sqlConnection=conn;
var sql:String="create table if not exists Notes" +
"(noteid integer primary key autoincrement" +
"title text,content text,publisher text)";
stmt.text=sql;
stmt.addEventListener(SQLErrorEvent.ERROR,error);
stmt.addEventListener(SQLEvent.RESULT,selectHandler);
stmt.execute(-1,null);//在运行的时候老是说我这一行有问题!
}
private function error(e:SQLErrorEvent):void{
Alert.show("Details:",e.error.message);
}
private function selectHandler():void{
Alert.show("successful!");
}
以下是错误提示:
ArgumentError: Error #1063: Argument count mismatch on localdata/createTable(). Expected 0, got 1.
at flash.data::SQLConnection/internalOpen()
at flash.data::SQLConnection/open()
at localdata/initApp()[C:\workspace\windowsoft\src\localdata.mxml:30]
at localdata/___localdata_WindowedApplication1_creationComplete()[C:\workspace\windowsoft\src\localdata.mxml:5]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:12528]
at mx.core::UIComponent/set initialized()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:1627]
at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:759]
at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1072]
请大家帮帮忙!谢谢了! |
|