[ASP] Open and Order CSV file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • viki1967
    Contributor
    • Oct 2007
    • 263

    [ASP] Open and Order CSV file

    Hi all.

    I need open with ASP one CSV file and order this file with field DESCRIPTION.

    Can you help me?

    kind regards
    viki
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    I googled the following words: "csv ado db driver asp"

    This was the top hit: "http://www.simongibson .com/intranet/adooledb/"

    Here is the code they provided:
    Code:
    <%@LANGUAGE=VBSCRIPT%>
    <%
    Option Explicit
    Dim strConnection, conn, rs, strSQL
    
    strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
    Server.MapPath(".\csv\") & ";Extended Properties=""text;HDR=Yes;FMT=Delimited"""
    
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.Open strConnection
    
    Set rs = Server.CreateObject("ADODB.recordset")
    strSQL = "SELECT * FROM myFile.csv"
    rs.open strSQL, conn, 3,3
    
    rs.MoveFirst
    WHILE NOT rs.EOF
         Response.Write(rs("myColumn") & "<br/>")
    rs.MoveNext
    WEND
    
    rs.Close
    Set rs = Nothing
    
    conn.Close
    Set conn = Nothing
    %>
    To sort by a specific field, you would want to change the strSQL to be "SELECT * FROM myFile.csv ORDER BY description"

    Jared

    Comment

    Working...