Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 9th, 2008, 10:11 PM
Registered User
Join Date: Nov 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Pulling unique data from 1 table insert into anoth

 need help with this please. This is driving me crazy.

I have an asp page that loads a CSV file into a table named emplist with the following collumns;

PayGroup varchar(15), LocationCode varchar(15), SupervisorName varchar(55), FileNumber varchar(15), LastName varchar(55), FirstName varchar(55)

This part works fine thus far. Where I run into trouble is; I then need to scan each row for the supervisor name and then insert each UNIQUE supervisorname into another table named jraspin which also has a collumn named supervisor with varchar(55)

so if supervisor names on the emplist table were =

john doe
john doe
john doe
jane smith
jane smith
jim Thomas

It would need to insert into jraspin the names, john doe, jane smith and jim thomas and not the duplicates and if only the name isn't already in the jraspin table

mySQL = "SELECT * FROM emplist " & _
" WHERE supervisorname <> '' " & _
" AND supervisorname <> 'supervisorname' " 
Set RS = Server.CreateObject("ADODB.Recordset") 
Rs.Open mySQL, DataConn, 0,1

' Count how many records exist
DIM isupcount, countsup,sql_select,strsupervisor, supervisor
strsupervisor = ""
isupcount = 0
If RS("supervisorname") <> countsup then
isupcount = isupcount + 1
countsup = RS("supervisorname") 
End If

' Display result
Response.Write "(" & isupcount & ")" 'this counts how many unique supervisor names
Set RS = nothing
Set RS = Server.CreateObject("ADODB.Recordset") 
Rs.Open mySQL, DataConn, 0,1

'insert into jraspin new supervisor names
For supervisor = 0 To isupcount ' this sets the count for supervisor using the number counted
If Rs("paygroup") <> strsupervisor Then ' uses to see if supervisor is a duplicate
supervisor = Rs("paygroup") ' this is the counting variable which should have multiple records
strsupervisor = Rs("paygroup")
End If
Set RS = Nothing 

'You will notice I have not included the insert function yet. I can't get past this part so need for 'that until I can figure out how to record each unique supervisor record.

Okay so there it is. I keep getting a mismatch error on the first name in the list; The count displays the right number of unique supervisors right before the error prints so that part is working obviously. Line 43 is my "next" command

Microsoft VBScript runtime error '800a000d'

Type mismatch: '[string: "C2A"]'

/hours/supcount2.asp, line 43

P.S. the dataconn variable is attached with an included file in the header which is defined as my db connection...

If first you don't succeed - Post in a forum.

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to insert unique filelds imagetvr Pro VB 6 2 September 9th, 2008 10:16 PM
DTS does not insert data into table kathytran20022002 SQL Server DTS 3 February 14th, 2006 02:59 PM
How do I insert data into multiple table ? bmalex1 PHP How-To 0 February 2nd, 2006 02:43 PM
Help! trying to insert data into a table ziwez0 Access VBA 3 January 8th, 2004 11:12 AM
Dynamically pulling table names from a database conundrum Access ASP 2 December 21st, 2003 07:49 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.