read csv file using ASP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vanishree04
    New Member
    • Feb 2010
    • 1

    read csv file using ASP

    Hi all
    I am new to ASP.I'm trying to retrieve the values of a column from an uploaded csv file, then insert this into an database. I exactly followed this link to display the data but it dint work ..it is giving a blank screen..please help...

    http://www.geekpedia.c om/tutorial143_Ext ract-data-from-Excel-Spreadsheet-using-ASP.html


    <%
    ' Set Connection Params
    Set oConn = Server.CreateOb ject("ADODB.con nection")
    oConn.Open "Driver={Micros oft Excel Driver (*.xls)}; DriverId=790;" &_
    "DBQ=c:\champ\s fox\Book.xls;" &_
    "DefaultDir = C:\champ\sfox\"

    Set RS=Server.Creat eObject("ADODB. recordset")

    ' Write the SQL Query
    RS.open "SELECT * FROM Test", oConn

    do until RS.EOF
    Response.Write ( RS("NAME") & " -- " & RS("EMAIL") & "")
    RS.movenext
    Loop

    'Close the recordset/connection

    RS.Close
    oConn.Close
    Set RS = Nothing
    %>


    Thanks
    Vani
  • CroCrew
    Recognized Expert Contributor
    • Jan 2008
    • 564

    #2
    Hello vanishree04,

    Ok, this may take a bit but I think you will get it and be able to accomplish what you’re trying to do:

    Let’s use a different provider to gain access to your Excel file (see below code). One of the most important attributes you need to look at when using this provider is the “HDR” setting. If the Excel file that you are using doers not have a header row then the setting needs to be set for "HDR=No". And each column is referred to a F# (ie: F1, F2, F3, and so on).

    Take a look at the code below and if you need me/us to elaborate more on what it does I/we will be happy too.

    Happy Coding,
    CroCrew~

    Code:
    <% 
    Set oConn = Server.CreateObject("ADODB.connection") 
    oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\champ\sfox\Book.xls;Extended Properties='Excel 8.0; HDR=No; IMEX=1'"
    
    Set RS=Server.CreateObject("ADODB.recordset") 
    
    RS.open "SELECT * FROM [Sheet1$]", oConn 
    
    do until RS.EOF
    Response.Write (RS("F1") & " -- " & RS("F2") & "<br />")
    RS.movenext
    Loop 
    
    RS.Close 
    oConn.Close 
    Set RS = Nothing 
    %>

    Comment

    Working...