Access and txt files

Results 1 to 2 of 2

Thread: Access and txt files

  1. #1
    KatieG Guest

    Default Access and txt files

    Hi, <BR><BR>I am wondering how to transfer data from a pipe delimited text file into the Access database on my server. The text files will be uploaded periodically but how do I get the data to export itself into my database???<BR><BR>Thanks in advance,<BR><BR>Catherine.

  2. #2
    Join Date
    Dec 1969

    Default RE: Access and txt files

    You need to use the File System object to read the text file, then use the Split function to separate the data with the pipes, and finally write that into the database.<BR><BR>Try something along the lines of:<BR><BR>Dim Fso, MyFile, MyString, MyArray <BR>Set Fso = Server.CreateObject("Scripting.FileSystemObject") <BR>Set MyFile = FSO.OpenTextFile("C:SomeWhereMyTextFile.txt",1) <BR>MyString = MyFile.ReadLine <BR>MyArray = Split(MyString,"&#124",-1,1) <BR>For i=0 to UBound(MyArray)<BR>&#039write to the database as the loop goes thru the array:<BR>mySQL="INSERT INTO MyTable VALUES (" & MyArray(i) & ")"<BR>Con.Execute mySQL<BR>Next<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts