importing csv into access db via asp

Discussion in 'ASP General' started by rob, Feb 7, 2004.

  1. rob

    rob Guest

    Hi all,

    I've got a csv file which I will need to import into an access db via asp.
    The csv file will be imported every day of each month so there will be
    duplicates which will not need to be imported. Any sample scripts pointing
    me in the right way would be great.

    Many thanks,
    Rob
    rob, Feb 7, 2004
    #1
    1. Advertising

  2. Rob,

    I spent today working on importing a csv/xls group of files and this may
    help you:

    <%
    ' create and open the connection to the database
    Set cn = Server.CreateObject("ADODB.Connection")
    ' create and open the recordset
    cn.open "ODBC;DBQ=c:\items.xls;Driver={Microsoft Excel Driver (*.xls)}"
    set rs=server.createobject("ADODB.recordset")
    rs.activeconnection=cn
    rs.source="select * from ITEMS"
    'NOTE: you will want to create a named range of all data cells in your
    CSV file
    'by highlighting them all, and typing a name in the cell name box in
    upper left
    'of excel sheet...then select from it as you would in sql...
    rs.open
    %>

    <TABLE Border=1 CellPadding=3>
    <TR>
    <% For col = 0 To RS.Fields.Count-2 %>
    <TH><% = RS.Fields(col).name %></TH>
    <% Next %>
    </TR>
    <% Do While Not RS.eof %>
    <TR>
    <% For col = 0 To RS.Fields.Count-2 %>
    <TD><% = RS.Fields(col).value %></TD>
    //here you can do whatever you need, as in write out to database...I am
    writing to arrays then building a new CSV file

    <% Next %>
    </TR>
    <% RS.MoveNext %>
    <% Loop %>
    </TABLE>

    <%
    rs.close
    cn.close
    set rs = nothing
    set cn = nothing
    %>


    Hope this helps some...

    Mike

    "rob" <> wrote in message
    news:c0395d$do0$...
    > Hi all,
    >
    > I've got a csv file which I will need to import into an access db via asp.
    > The csv file will be imported every day of each month so there will be
    > duplicates which will not need to be imported. Any sample scripts

    pointing
    > me in the right way would be great.
    >
    > Many thanks,
    > Rob
    >
    >
    Michael Wendell, Feb 8, 2004
    #2
    1. Advertising

  3. rob

    Bullschmidt Guest

    <<
    I've got a csv file which I will need to import into an access db via
    asp.
    The csv file will be imported every day of each month so there will be
    duplicates which will not need to be imported. Any sample scripts
    pointing
    me in the right way would be great.
    >>


    You can connect to a csv file (which can be opened in Excel and which an
    Excel file can be converted into) in good form just as you can to a
    regular database.

    And you can have two recordsets open at the same time.

    So I'd suggest going through this recordset one row at a time and within
    this loop add a new record to the "real" database's recordset.

    And for help connecting to a text file using the Jet OLE DB provider:
    http://www.able-consulting.com/MDAC/ADO/Connection/OLEDB_Providers.htm#O
    LEDBProviderForMicrosoftJetText

    And based on the above link realize that the actual filename does NOT go
    in the connection string - rather it goes in the SQL statement
    (definitely a little tricky).

    Best regards,
    J. Paul Schmidt, Freelance ASP Web Developer
    http://www.Bullschmidt.com
    ASP Design Tips, ASP Web Database Demo, Free ASP Bar Chart Tool...


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Bullschmidt, Feb 10, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. klia
    Replies:
    0
    Views:
    284
  2. James Mills

    Re: importing csv file into sqlite

    James Mills, Dec 18, 2008, in forum: Python
    Replies:
    3
    Views:
    1,592
    John Machin
    Dec 19, 2008
  3. klia
    Replies:
    4
    Views:
    1,615
    John Machin
    Dec 19, 2008
  4. Chris Rebert

    Re: importing csv file into sqlite

    Chris Rebert, Dec 18, 2008, in forum: Python
    Replies:
    1
    Views:
    515
    Peter Otten
    Dec 18, 2008
  5. John Mcleod
    Replies:
    2
    Views:
    74
    7stud --
    Jul 23, 2009
Loading...

Share This Page