Reading CSV data

Results 1 to 3 of 3

Thread: Reading CSV data

  1. #1
    Join Date
    Dec 1969

    Default Reading CSV data

    Hi - can anyone help me out with this please??<BR><BR>My client wants to add new contacts to his database via an interface which allows him to upload a CSV file - data from this file should then automatically be inserted into the database. <BR><BR>I have got as far as getting the CSV file uploaded but don&#039;t know how to get the CSV data from the .csv file into the table.<BR><BR>Any advice would be very appreciated!<BR><BR>Lisa<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default Text ODBC Driver

    You can install a Text ODBC Driver and then refer to the file as if it were a database table.

  3. #3
    Join Date
    Dec 1969

    Default RE: Reading CSV data

    exactly what im doing at the moment user the filesystem object<BR><BR><BR>go read up on it 8o)<BR><BR><BR>&#039;Create an instance of the FileSystemObject object<BR>Set objFSO = Server.CreateObject("Scripting.FileSystemObject") <BR><BR>Set objTextStream = objFSO.OpenTextFile(strTemplatePath,1)<BR><BR>&#03 9; Read the content into strBody<BR>strBody = objTextStream.ReadAll<BR><BR>should read the file into the strBody variable which you can then split and join to dynamically create a sql insert command<BR><BR><BR>strLine1 = objFile.Readline<BR>while not objFile.EOF<BR>objDBConn.Execute "insert into tablename (" & join(split(strLine1, vbTab), ", " & ") values (&#039;" & join(split(objFile.ReadLine, vbTab), "&#039;, &#039;") & "&#039;)"<BR>next

Posting Permissions

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