|
|
 |
| Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Databases section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

January 3rd, 2005, 05:38 PM
|
|
Registered User
|
|
Join Date: Dec 2004
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ASP to read .CSV into Access
Okay, I am trying to read a .csv file line by line and insert the records into a database through ASP. I can Response.Write sSeg() to the screen, but when I try to insert the records into the database it gives me:
Microsoft JET Database Engine (0x80040E14)
Syntax error in INSERT INTO statement.
/technology/test/gls/import_action.asp, line 32
It works fine if I just insert the first field (sequence), but when I try to insert all four fields it gives me the error. Here is my code:
<%
'CONNECT TO THE DATABASE
set objconn = Server.CreateObject("ADODB.Connection")
objconn.Provider="Microsoft.Jet.OLEDB.4.0"
objconn.Open Server.MapPath("csv.mdb")
csv_to_read="test.csv"
set fso = createobject("scripting.filesystemobject")
set act = fso.opentextfile(server.mappath(csv_to_read),1,Fal se)
dim sline
dim sSeg
Do Until act.AtEndOfStream
sline=act.readline
sSeg=split(sline,",")
dim strsql
strsql="INSERT INTO CSV (Sequence, Text, Name, Grade)"
strsql=strsql & "VALUES('"&sSeg(0)&"', '"&sSeg(1)&"',
'"&sSeg(2)"', '"&sSeg(3)&"')"
objconn.execute strsql
loop
act.close
set act=nothing
'CLOSE THE CONNECTION AND CLEAN UP
objconn.close
set objconn=nothing
%>
Sequence, Text, Name, and Grade are all text fields in my database. The .CSV is comma delimmited.
If anyone has any suggestions I would really appreciate it.
Thanks
|

January 4th, 2005, 11:01 AM
|
|
Registered User
|
|
Join Date: Dec 2004
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks....but I figured it out. My field name 'text' was throwing it off. Keyword maybe?
Oh well it works....thanks
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |