Jump to content

Import CSV into ACCESS


andreathedove

Recommended Posts

Hola.I have a question on Importing CSV to Access.I have this csv file:http://www.allinonenet.it/FINO-clickpoint.csvI have this code

<%@ Language="VBScript" %><%  '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="FINO-clickpoint.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,",") <-- Here. I don't know what to replace.  dim strsql  strsql="INSERT INTO CSV (CompanyID, CompanyName, Address, Country)"  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%>

How can I resolve the problem ?Thanks,Andrea

Link to comment
Share on other sites

Hola.I have a question on Importing CSV to Access.I have this csv file:http://www.allinonenet.it/FINO-clickpoint.csvI have this code
<%@ Language="VBScript" %><%  '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="FINO-clickpoint.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,",") <-- Here. I don't know what to replace.  dim strsql  strsql="INSERT INTO CSV (CompanyID, CompanyName, Address, Country)"  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%>

How can I resolve the problem ?Thanks,Andrea

Hello,I try:
<%@ Language="VBScript" %><%  'CONNECT TO THE DATABASE  set objconn = Server.CreateObject("ADODB.Connection")  objconn.Provider="Microsoft.Jet.OLEDB.4.0"  objconn.Open Server.MapPath("mdb-database/csv.mdb")  csv_to_read="FINO-clickpoint.csv"  set fso = createobject("scripting.filesystemobject")  set act = fso.opentextfile(server.mappath(csv_to_read),1,False)  dim sline  dim sSeg    Do Until act.AtEndOfStream    sline=act.readline  sSeg=split(sline,";")  dim strsql  strsql="INSERT INTO CSV (id, categoria)"  strsql=strsql & "VALUES('"&sSeg(0)&"', '"&sSeg(1)&"')"  objconn.execute strsql       loop  act.close  set act=nothing     'CLOSE THE CONNECTION AND CLEAN UP  objconn.close  set objconn=nothing%>

but it give me this errorhttp://www.allinonenet.it/csv.aspwhy?Andrea

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...