Import .csv into Access db

Results 1 to 2 of 2

Thread: Import .csv into Access db

  1. #1
    Join Date
    Dec 1969

    Default Import .csv into Access db

    I need to write a script that will allow a user to select a .csv file on their local machine and import it into an Access db on the server?<BR><BR>How can this be done with ASP?<BR><BR>Thanks!

  2. #2
    Join Date
    Dec 1969

    Default Well, first you have to upload it...

    ...from the user machine to the server.<BR><BR>*PLEASE* don&#039;t tell me you are going to use one of those crappy written-in-vbscript uploaders. Please tell me that the host you are using has an upload component available for use.<BR><BR>Once the CSV file is on the server, you *can* just treat it as a database! Yes, the "Microsoft Text Driver" *can* treat CSV files almost the same as any other Jet database.<BR><BR>In fact, from within an Access SQL query, you can refer to the CSV file. So it might be as simple as doing something akin to<BR> INSERT INTO accessTable (field1, field2, field3)<BR> SELECT fieldX, fieldY, fieldZ FROM CSVfile<BR><BR>The "trick" is in addressing the CSVfile correctly. For that, try looking here:<BR><BR><BR>Look at this example and imagine substituting in the driver info for a CSV text file in place of the stuff in italics:<BR> SELECT CustomerID<BR> FROM Customers<BR> IN [dBASE IV;DATABASE=C:DBASEDATASALES;]<BR> WHERE CustomerID Like A*;<BR><BR><BR>But, anyway, if you can&#039;t get that to work, then you *could* script Access as an ActiveX object and give "commands" to Access to import the file.<BR><BR>Lastly, you could simply parse the CSV file in VBS code and insert the records into Access one at a time.<BR><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