我正在adobe air制作一个关于在牙科中心保存患者数据和所有记录的项目,我想在第一次打开程序时询问主计算机和同一网络上的其他计算机上的数据库数据库的路径并打开它并保存它的位置,当我第二次打开程序时,它会自动通过网络打开数据库,而不会询问路径。我试图在共享对象中保存路径,但它没有任何想法的人工作? 抱歉,我没有在这里发布代码(这里的代码现在正在使用我正在使用fileReference但现在使用的是文件类,它的工作方式就像魔术一样,但是我想问一下,如果我从一台计算机上做了更改,它将被保存,如果用多台计算机打开数据库?):
import flash.filesystem.File;
import flash.net.SharedObject;
import flash.net.FileReference;
import flash.events.Event;
import flash.data.SQLConnection;
import flash.data.SQLStatement;
import flash.data.SQLResult;
import flash.data.SQLSchema;
import flash.errors.SQLError;
import flash.events.SQLErrorEvent;
import flash.events.SQLEvent;
import flash.data.SQLMode;
var myDatabase: File = new File();
var dbFilter: FileFilter = new FileFilter("Database", "*.db");
var connection: SQLConnection = new SQLConnection();
var setting: SharedObject = SharedObject.getLocal("shardd");
if (setting.data.firstRun == undefined) {
setting.data.firstRun = 0;
trace("First Run");
chooseDatabaseLocation();
} else {
trace("Not First Run");
//setting.data.firstRun = 0;
myDatabase.nativePath = setting.data.databaseFile;
openDatabase();
}
function chooseDatabaseLocation() {
myDatabase.browseForOpen("Open Database", [dbFilter]);
myDatabase.addEventListener(Event.SELECT, databaseSelected)
}
function databaseSelected(Event) {
trace("databaseSelected");
setting.data.databaseFile = myDatabase.nativePath;
openDatabase();
}
function openDatabase() {
trace("openDatabase: "+myDatabase.nativePath);
connection = new SQLConnection();
connection.addEventListener(SQLEvent.OPEN, loadInfo);
connection.openAsync(myDatabase, SQLMode.UPDATE);
}
function loadInfo(SQLEvent):void
{
trace("loadInfo");
var stat:SQLStatement = new SQLStatement();
stat.sqlConnection = connection;
stat.text = "SELECT id, direct FROM general_info WHERE id=1";
stat.execute(-1, new Responder(showInfo));
}
function showInfo(evt:SQLResult){
trace("showInfo");
if (evt.data != null)
{
direct_txt.text = evt.data[0].direct;
}else{
direct_txt.text = "No data";
}
}