|
|||
|
I've got a problem with my dbf connection through swfkit.
The dbf-file is created with an outdated dbf program, therefore i must change the first bitvalue as pointed in this post: Code:
function ChangeFile(){
trace("Copy original file to app-dir and change it")
// Original file is in this folder
path = "c:\\DOELFOLDER\\ordp.dbf";
src = new File(path);
trace(src.name)
destPath = doelpuntmap
b = getAppDir() + "dp.dbf"
src.copy(b);
var f = new FileStream(b, "r+");
f.put(0x03);
f.close();
}
Then I try to connect to the dp.dbf-file like this: Code:
function getDBFRecords(){
conn2= new ActiveXObject("ADODB.Connection");
conn2.connectOK = false;
conn2.ConnectComplete = function (err, status, cnt){
trace(err.Description+" " + status.value)
if (typeof err != "undefined"){
trace(err.Description);
return;
}else{
conn2.connectOK = true;
trace("Connect complete!");
}
}
conn2.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+getAppDir()+";Extended Properties='dBase IV';");
if (!conn2.connectOK){
trace("Failed to connect to the DB");
return;
}
var ds = new ActiveXObject("ADODB.Recordset");
ds.open("select * from dp.dbf", conn2, 1, 2);
dpdoelen = []
ds.moveFirst();
for(var i=0;i<200;i++){
if(ds.Fields["DOEL"].value){
dpdoelen.push({naam:ds.Fields["ONDEEL"].value.toString()+"___"+ds.Fields["DOEL"].value.toString()+"|"+ds.Fields["NUMMER"].value})
ds.moveNext()
trace(ds.Fields["DOEL"].value.toString())
}else{
break;
}
}
ds.close()
return dpdoelen
}
But when I try the code seperatly (without changing the file at the same time) with the changed file, it works. Another issue is that I can only see the records in preview mode. When i compile the program, it doesn't work anymore! My sourcefile can be downloaded here Any help is appreciated Last edited by meester; 03-16-2009 at 07:09 PM. |
|
|||
|
The reason of the problem that your program cannot work when compiled to an exe is that you stop it if there is an error during the database connection. However, it seems that there will always be an error during the connections to your dbf file, and the error doesn't matter, because the ADO objects can still get the records successfully. So the solution is to simply comment the error checking lines, as you can see from the attached file.
And this also solves the another problem that you cannot connect the dbf file immediately after changing it. |
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|