Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: OLE DBF to XML Converter
Courtesy of Stan Littlefield
We are in the Process of moving a lot of legacy DBF files and file structures to Oracle.
We are using XML as an intermediate.
The attached script will prompt the user for a DBF file, then create two XML files, one with the DBF structure, the other with the data. Once in XML the data can be re-constructed in a variety of formats through OLE. An ini file is created/updated to illustrate the connect string, path, table, and schema variables used.
; /////////////////////////////////////////////////////// ; Winbatch OLE DB Script ; ; Prompts user for DBF File name. Opens the file with the Jet ; 4.0 Provider, creates separate .XML files for both the Table ; Structure and the Data. ; ; DBF.ini will be created the first time the script is run (in ; the same subdir as the script) to illustrate the connection and ; the files created ; ; [Main] ; Path=C:\wbdemo\ ; Table=Goods ; XML=C:\wbdemo\Goods.XML ; Schema=C:\wbdemo\GoodsSchema.XML ; Conn=Provider=MicroSoft.Jet.OLEDB.4.0; Data Source=C:\wbdemo\; ; Extended Properties=dBASE III;; 4. Create Column objects, append to new Table ; ; Stan Littlefield 06/29/2000 ; /////////////////////////////////////////////////////// cDbf = AskFilename( "Select DBF To Link", DirGet(), "dBASE III|*.DBF","*.DBF",1) cPath = FilePath(cDbf) cDbf = FileNameShort(cDbf) nDbf = StrIndexNc(cDbf,".",1,@FWDSCAN) cDbf = StrSub(cDbf,1,nDbf-1) cXML = strcat(cDbf,".XML") cSch = strcat(cDbf,"Schema.XML") cDbf = StrSub(cDbf,strlen(cPath)+1,-1) cConn = strcat("Provider=MicroSoft.Jet.OLEDB.4.0; Data Source=",cPath,"; Extended Properties=dBASE III;") cSQL = strcat("SELECT * FROM ",cDbf) IniWritePvt("Main","Path",cPath,".\dbf.ini") IniWritePvt("Main","Table",cDbf,".\dbf.ini") IniWritePvt("Main","XML",cXML,".\dbf.ini") IniWritePvt("Main","Schema",cSch,".\dbf.ini") IniWritePvt("Main","Conn",cConn,".\dbf.ini") IF FileExist(cXML) == @TRUE FileDelete(cXML) Endif IF FileExist(cSch) == @TRUE FileDelete(cSch) Endif cMode = IniReadPvt("Main","Mode","1",".\dbf.ini") BoxOpen("Transferring %cDbf% To XML","Opening Data Source") DB = ObjectOpen("ADODB.Connection") DB.Open(cConn) RS = DB.Execute(cSQL) ;Now Describe BoxText("Translating RecordSet To XML") RS.Save(cXML,1) ObjectClose(RS) adSchemaTables=20 RS = DB.OpenSchema(adSchemaTables) RS.Save(cSch,1) ObjectClose(RS) DB.close() ObjectClose(DB) BoxShut() exit
Article ID: W14669
Filename: DBF to XML Converter.txt
File Created: 2000:06:29:11:30:00
Last Updated: 2000:06:29:11:30:00