Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import/Export using asp to csv

Status
Not open for further replies.

discus364

Technical User
Nov 5, 2007
2
AU
Hi,

I am trying to work out how to export/import information from an asp page into a csv file.

The csv file contains employee names and their department in 2 columns..Name and Team. What I want to be able to do is to add and remove names from this page using a submit function

As you can see from my code I am currently able to view 2 columns from the csv file in dropdown boxes on my asp page. I don't however how to overwrite records in it should someone change teams or delete someone if they leave

Any pointers or assistance would be apppreciated

Code:
</table>		     
<%
set rs = Server.CreateObject("ADODB.recordset")
set rs1 = Server.CreateObject("ADODB.recordset")
Dim sConn, sSource, sResults
sConn = "DRIVER={Microsoft Text Driver (*.txt; *.csv)};" & "DefaultDir=" & "\\nsyd9009pap\c$\Inetpub\[URL unfurl="true"]wwwroot\GMS_Stats\Stats\db2\"[/URL] & ";Extensions=asc,csv,tab,txt"
sSource = "Select [Name] FROM [TestEmployees.csv]"
sSource1 = "Select [Team] FROM [TestEmployees.csv]"
rs.Open sSource, sConn, adOpenKeyset
rs1.Open sSource1, sConn, adOpenKeyset
%>	     

<table>
	<tr>
	  <td>Name</td>
	  </tr>
	 </table> 

<select>

<%for each x in rs.Fields
    next%>
<%do until rs.EOF%>
    <%for each x in rs.Fields%>
       <option value=<<%Response.Write(x.value)%>><%Response.Write(x.value)%></option>
    <%next
    rs.MoveNext%>
<%loop
rs.close
%>

</table>

<table>
<tr>
<td>Team</td>
</tr>
</table>
<table>
 
Sorry...didn't include all the code...

Code:
<%
set rs = Server.CreateObject("ADODB.recordset")
set rs1 = Server.CreateObject("ADODB.recordset")
Dim sConn, sSource, sResults
sConn = "DRIVER={Microsoft Text Driver (*.txt; *.csv)};" & "DefaultDir=" & "\\nsyd9009pap\c$\Inetpub\[URL unfurl="true"]wwwroot\GMS_Stats\Stats\db2\"[/URL] & ";Extensions=asc,csv,tab,txt"
sSource = "Select [Name] FROM [TestEmployees.csv]"
sSource1 = "Select [Team] FROM [TestEmployees.csv]"
rs.Open sSource, sConn, adOpenKeyset
rs1.Open sSource1, sConn, adOpenKeyset
%>	     

<table>
	<tr>
	  <td>Name</td>
	  </tr>
	 </table> 

<select>

<%for each x in rs.Fields
    next%>
<%do until rs.EOF%>
    <%for each x in rs.Fields%>
       <option value=<<%Response.Write(x.value)%>><%Response.Write(x.value)%></option>
    <%next
    rs.MoveNext%>
<%loop
rs.close
%>

</table>

<table>
<tr>
<td>Team</td>
</tr>
</table>
<table>
<div>
<select>
<%for each x in rs1.Fields
    next%>
<%do until rs1.EOF%>
    <%for each x in rs1.Fields%>
       <option value=<<%Response.Write(x.value)%>><%Response.Write(x.value)%></option>
    <%next
    rs1.MoveNext%>
<%loop
rs1.close
%>
</table>


</body>
</html>
</code]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top