user upload / bulk add - Posted (1236 Views)
Junior Member
chumbawumba
Posts: 304
304
Hello

does anybody have code to bulk add users from a .csv file into snitz. I need the code to be able to open the text file and then insert the users into the DB

thanks smile<
 Sort direction, for dates DESC means newest first  
 Page size 
Posted
Junior Member
chumbawumba
Posts: 304
304
does anyone have any similar code that I can use as a starting point? TIA<
Can't stop, lose job, mind gone, silicon.
Posted
Forum Admin
HuwR
Posts: 20611
20611
doesn't look like, it. in general you would copy user records from one db to another, why do you have them in a csv file ?
depending on the database you are using, there is usually functionality in the database tools to import data from a csv file<
Posted
Junior Member
chumbawumba
Posts: 304
304
I have found some working code from wrox.com

The HR department have outputted a list of employees from one DB that need uploading into a different DB. The systems aren't linked. A convenient way to enter the users was through reading a csv file. Anyway thanks problem solved.<
Posted
Senior Member
muzishun
Posts: 1079
1079
Would you mind posting the code (and possibly the format your csv file is in) for others who may need it in the future?<
Bill Parrott
Senior Web Programmer, University of Kansas
Co-Owner and Code Monkey, Eternal Second Designs (www.eternalsecond.com)
Personal Website (www.chimericdream.com)
Posted
Average Member
kolucoms6
Posts: 845
845
Right.<
Posted
Junior Member
chumbawumba
Posts: 304
304
OK, here is the code to be used as a starting point:

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,False)

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
%>

<
 
You Must enter a message