Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-15-2009, 01:09 PM
Senior Member
 
Join Date: Feb 2003
Posts: 212
Default DBF-file drives me crazy

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();
    
}
This code is working.

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
}
When I run this code just after i changed the file, I can't connect to the database.
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 06:09 PM.
Reply With Quote
  #2 (permalink)  
Old 03-17-2009, 10:21 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default

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.
Attached Files
File Type: zip dbf2.zip (1.3 KB, 12 views)
Reply With Quote
  #3 (permalink)  
Old 03-17-2009, 10:48 AM
Senior Member
 
Join Date: Feb 2003
Posts: 212
Default

Works like a charm!!
You're the best!!

Last edited by meester; 03-17-2009 at 02:51 PM.
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 05:40 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.