473,473 Members | 2,080 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

importing csv into access db via asp

rob
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
Jul 19 '05 #1
2 1864
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" <rl*****@supanet.com> wrote in message
news:c0**********@hercules.btinternet.com...
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

Jul 19 '05 #2
<<
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!
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Grim Reaper | last post by:
I am importing a .csv file into Access that has 37 fields. My problem is that sometimes the last field only has data at the end of the column (it looks like when you import a file into Access, for...
1
by: sparks | last post by:
I have never done this and wanted to ask people who have what is the best way. One person said import it to excel, then import it into access table. but since this will be done a lot, I am...
7
by: Darren | last post by:
I have been attempting to create a reservation planning form in excel that imports Data from an Access database and inserts that information automaticly into the correct spreed sheet and the...
5
by: dixie | last post by:
If I sent a user an empty database container - dB with no tables and I needed them to import their tables into it and one of their tables was a hidden table with the prefix Usys, is there any way...
2
by: nutthatch | last post by:
I want to be able to import an Excel spreadsheet into Access 2K using the macro command Transferspreadsheet. However, the file I am importing (over which I have no control) contains some records...
1
by: winzy | last post by:
I have a table in Access which needs updating from an Excel file. Instead of importing the whole Excel like a new table in Acess, how do I do a partial import/update?? For example, Access table...
5
by: hharriel | last post by:
Hi, I am hoping someone can help me with an issue I am having with excel and ms access. I have collected data (which are in individual excel files) from 49 different school districts. All...
1
by: ltikusis | last post by:
I am currently using the trial version of MapPoint 2006 and I am having problems mapping data from Access queries. When importing a query, MapPoint does not match any of the fields to the map. I've...
3
by: mukeshsrivastav | last post by:
dear sir i want to move form excel to access. i have 5 excel file having same formats and fields.now i want to import all data in one access table. importing one file is easy .but importing and...
1
by: aconti74 | last post by:
Hello I am new to vba programming/coding. I am writing a program that goes through a directory of text files and imports them into the database. The problem is eventually the database gets to big...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.