Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/O Code)
 user upload / bulk add
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

chumbawumba
Junior Member

United Kingdom
304 Posts

Posted - 15 May 2007 :  00:54:07  Show Profile  Reply with Quote
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 <

chumbawumba
Junior Member

United Kingdom
304 Posts

Posted - 17 May 2007 :  21:46:46  Show Profile  Reply with Quote
does anyone have any similar code that I can use as a starting point?
TIA<

Can't stop, lose job, mind gone, silicon.
Go to Top of Page

HuwR
Forum Admin

United Kingdom
20584 Posts

Posted - 18 May 2007 :  05:00:35  Show Profile  Visit HuwR's Homepage  Reply with Quote
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<
Go to Top of Page

chumbawumba
Junior Member

United Kingdom
304 Posts

Posted - 20 May 2007 :  07:31:01  Show Profile  Reply with Quote
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.<
Go to Top of Page

muzishun
Senior Member

United States
1079 Posts

Posted - 20 May 2007 :  11:14:51  Show Profile  Visit muzishun's Homepage  Reply with Quote
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)
Go to Top of Page

kolucoms6
Average Member

845 Posts

Posted - 20 May 2007 :  17:08:36  Show Profile  Reply with Quote
Right.<
Go to Top of Page

chumbawumba
Junior Member

United Kingdom
304 Posts

Posted - 23 May 2007 :  00:53:53  Show Profile  Reply with Quote
OK, here is the code to be used as a starting point:


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


<
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.15 seconds. Powered By: Snitz Forums 2000 Version 3.4.07