user upload / bulk add

Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/64768?pagenum=1
05 November 2025, 09:06

Topic


chumbawumba
user upload / bulk add
15 May 2007, 00:54


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<

 

Replies ...


chumbawumba
17 May 2007, 21:46


does anyone have any similar code that I can use as a starting point? TIA<
HuwR
18 May 2007, 05:00


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<
chumbawumba
20 May 2007, 07:31


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.<
muzishun
20 May 2007, 11:14


Would you mind posting the code (and possibly the format your csv file is in) for others who may need it in the future?<
kolucoms6
20 May 2007, 17:08


Right.<
chumbawumba
23 May 2007, 00:53


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

<
© 2000-2021 Snitz™ Communications