Jump to content
Sign in to follow this  
sensalim

How to create a DBF file?

Recommended Posts

sensalim

Is there a way to create a dbf (IV) file?

I did a search and found one but very confusing.

Was hoping someone had made Dbf.au3 (to be <include>d) and then use functions like:

$a = CreateDBF( filename [, path])

AddHeader( $a, col1 [, col2, ...])

AddRow( $a, row1 [, row2, ...])

CloseDBF( $a )

or whatever.

Thanks for any help.

Share this post


Link to post
Share on other sites
ResNullius

Is there a way to create a dbf (IV) file?

I did a search and found one but very confusing.

Was hoping someone had made Dbf.au3 (to be <include>d) and then use functions like:

$a = CreateDBF( filename [, path])

AddHeader( $a, col1 [, col2, ...])

AddRow( $a, row1 [, row2, ...])

CloseDBF( $a )

or whatever.

Thanks for any help.

What you need are ADO functions along with a DBF COM/ODBC provider (Windows usually has dbase compatible ones installed by default).

Don't think anybody's made a udf specifically for DBF yet... <_< ... but easy enough to adapt some of the other ones that are out there for things like SQLite, etc

Share this post


Link to post
Share on other sites
ptrex

@all

This is a start :

;Create RecordSet and DBF objects
$ADORS = ObjCreate("ADODB.Recordset")
$DBF = ObjCreate("RSConvert.DBF")
 
;Open table
$ADORS.Open ("Orders", "DSN=ADOSamples")

;Close recordset
$ADORS.Close

; Open a DB IV Database
Func OpenDBFConn($Path)
  Local $Conn
  $Conn = ObjCreate("ADODB.Connection")
  $Conn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;" & _
                   "Data Source=" & $Path & ";" & _
                   "Extended Properties=""DBASE IV;"";" )
  $OpenDBFConn = $Conn
EndFunc

regards

ptrex

Share this post


Link to post
Share on other sites
ptrex

@all

This will actually create the DBF file

Const $Jet10 = 1
Const $Jet11 = 2
Const $Jet20 = 3
Const $Jet3x = 4
Const $Jet4x = 5

;Create .DBF IV database
CreateNewMDB ("\Test.dbf", $Jet4x)

Func CreateNewMDB($FileName, $Format)
  Local $Catalog
  $Catalog = ObjCreate("ADOX.Catalog")
  $Catalog.Create ("Provider=Microsoft.Jet.OLEDB.4.0;" & _
     "Jet OLEDB:Engine Type=" & $Format & _
    ";Data Source=" & @MyDocumentsDir & "\" & $FileName )
EndFunc

regards

ptrex

Edited by ptrex

Share this post


Link to post
Share on other sites
sensalim

Yes that whitetown... I tried but it doesn't convert a column properly.

This column has about 100-800 characters and the program splits it

into multiple columns.

I emailed them 2 days ago, no replies so far.

@ptrex:

I'm so green on these stuffs...

what do I do with

$DBF = ObjCreate("RSConvert.DBF")

Sample maybe? open dbf, write a column and a row, close...

Many thanks!

Share this post


Link to post
Share on other sites
sensalim

@all

This will actually create the DBF file

Const $Jet10 = 1
Const $Jet11 = 2
Const $Jet20 = 3
Const $Jet3x = 4
Const $Jet4x = 5

;Create .DBF IV database
CreateNewMDB ("\Test.dbf", $Jet4x)

Func CreateNewMDB($FileName, $Format)
  Local $Catalog
  $Catalog = ObjCreate("ADOX.Catalog")
  $Catalog.Create ("Provider=Microsoft.Jet.OLEDB.4.0;" & _
     "Jet OLEDB:Engine Type=" & $Format & _
    ";Data Source=" & @MyDocumentsDir & "\" & $FileName )
EndFunc

regards

ptrex

Hi,

It did create ... but what's in it?

I can't open (view) it with excel...

also how do you know all these stuffs lol... like using ADOX.Catalog... what *IS* that...

Edited by sensalim

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.