Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > importing csv into access db via asp

Reply
Thread Tools

importing csv into access db via asp

 
 
rob
Guest
Posts: n/a
 
      02-07-2004
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


 
Reply With Quote
 
 
 
 
Michael Wendell
Guest
Posts: n/a
 
      02-08-2004
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
>
>



 
Reply With Quote
 
 
 
 
Bullschmidt
Guest
Posts: n/a
 
      02-10-2004
<<
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/...roviders.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!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Searching/Comparison of CSV then importing into database John Mcleod Ruby 2 07-23-2009 06:54 AM
Re: importing csv file into sqlite James Mills Python 3 12-19-2008 02:08 PM
Re: importing csv file into sqlite klia Python 4 12-19-2008 01:58 PM
Re: importing csv file into sqlite Chris Rebert Python 1 12-18-2008 09:28 AM
importing csv file into sqlite klia Python 0 12-18-2008 05:58 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57