Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is pretty easy, and there is no reason to thunk over into the Desktop Text ODBC Driver because Jet 4.0 has a Text Installable ISAM that can do the job.</p> <p>Examples: Append text to existing table, import text as new table.</p> <pre><code>Private Sub cmdAppend_Click() Dim lngRows As Long conDB.Execute _ "INSERT INTO ExistingTable SELECT * " _ &amp; "FROM [Import.txt] IN '" &amp; App.Path &amp; "' 'TEXT;'", _ lngRows, _ adCmdText Or adExecuteNoRecords MsgBox CStr(lngRows) &amp; " rows appended to ExistingTable." End Sub Private Sub cmdImport_Click() Dim lngRows As Long conDB.Execute _ "SELECT * INTO NewTable " _ &amp; "FROM [Import.txt] IN '" &amp; App.Path &amp; "' 'TEXT;'", _ lngRows, _ adCmdText Or adExecuteNoRecords MsgBox CStr(lngRows) &amp; " rows imported as NewTable." End Sub </code></pre> <p>The key to making this work is to have a file named <code>Schema.ini</code> <em>in the same folder as the text file</em> (in this case I'm just using the App.Path folder for demonstration):</p> <pre><code>[Import.txt] Format = Delimited( ) TextDelimiter = none ColNameHeader = False MaxScanRows = 0 Col1="Code" Text Width 9 Col2="Sequence" Text Width 10 Col3="Type" Integer Width 1 </code></pre> <p>Above I made up field names and data types, which in a real case would match those in your database. <em>Be sure to note the single blank space between the parentheses</em> which will be the delimiting character used.</p> <p>If you have several text files in the same folder to import just add additional INI sections to Schema.ini as needed.</p> <p>Your program could even write such a Schema.ini to the folder dynamically if required, inserting the necessary text file name, list of fields and their names, type, sizes, etc.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload