title: How can I create a D-Base IV table using Delphi ADO components please?
body: <p>I am working on the software for an instrument that logs batch results into single DBase 4 (*.dbf) disk files in a folder. In preparation for adding new logging analysis capability which is planned to work with multiple of these DBF files, I am changing the existing simple BDE TTable and CreateTable which reopen and create a new DBF file respectively into use of the Delphi ADO components.</p>
  
  <p>Using other suggestion here on SO I have successfuly created a test application which opens an existing DBF file using the following core code using a TAdoDataSet and a TAdoConnection:</p>
  
  <pre><code>ADODataSet1.DisableControls;
  try
    S := ExtractFileDir( ParamStr(0) ); //set the dbf folder location here
    ADOConnection1.LoginPrompt:=false;
    ADOConnection1.ConnectionString:=Format('Provider=Microsoft.JET.OLEDB.4.0;Data Source=%s;Extended  Properties=dBase IV;',[S]);
    ADOConnection1.Connected:=True;
    ADODataSet1.CommandText:='Select * from test.dbf'; //The SQL query uses the name of the dbf file
    ADODataSet1.Open;
  finally
    AdoDataSet1.EnableControls;
  end;
  </code></pre>
  
  <p>This works fine but before my DBF is used for the first time I will also need to creat an empty DBF file ready to add my log records. I could do this by opening an exising 'empty' DBF file each time but I was hoping that there was an SQL? way of creating my file if I have already created and defined my fields (which is easy for me). I tried this with a TAdoTable where I could created the required fields but I could not find any examples of how to get this table structure out onto disk when nothing was already there, mainly because there are so many ADO examples but almost always working on existing data tables.</p>
  
  <p>Can anyone help me create a sample DFB table file with a couple of fields using ADO components please? I'm sure I can then build on that.</p>
  
  <p>Many Thanks.</p>