Advertisement

10.23.2007 at 10:46AM PDT, ID: 22912513
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.8

Classic ASP VBScript:  How to insert individual records from a comma-delimited list.

Asked by lshane in Active Server Pages (ASP), Microsoft Access Database

Tags: , , ,

Classic ASP VBScript
DWMX
MS Access
WIN XP PRO

Hello.  Recently I received assistance from EE regarding "splitting" a comma-delimited list into individual links.  That worked well.  However, it seems I am needing to take it one step further.

I have one simple form with a few basic fields such as First and Last names and a list of checkboxes corresponding with a dynamic recordset of mentees.  The checkboxes are bound to the ID's of any "team_member" with a "tm_Level" of "newhire".  

2 tables:  [team_members] and [team_mentees]

[team_members] -
{tm_ID} - numeric
{tm_First} - text
{tm_Last} - text
{tm_Mentor} - checkbox of Y or N
{tm_mentee} - comma-delimited list (bound to the value of "tm_ID")

[team_mentees]
{mentee_ID} - text (to be received from the comma-delimited list of "tm_mentee")
{mentor_ID} - numeric (to be received from the "tm_ID" form field)

The following is the code segment I received from EE (which works great):
===================================================================================
<%dim strLinks
strLinks = split(rsMenteeList.Fields.Item("tm_mentee").Value, ",")
for i = 0 to ubound(strLinks)
    response.write("<a href=""some_process_page.asp?MenteeNumber=" & trim(strLinks(i)) & """>" & trim(strLinks(i)) & "</a><br />")
next%>
===================================================================================

Question:  
The form will POST to a process page which needs to add the "mentor_ID" to the [team_mentees] table AND separate each selected checkbox (which corresponds, or is bound, to the "tm_ID" value of any team member with a "tm_Level" of "newhire") and INSERT an individual record for each one in the "mentee_ID" field of the [team_mentees] table.

By using the following "Command" code below, I can get it to write all selected checkboxes to the "mentee_ID" field of the [team_mentees] table, but it is still in comma-delimited format.  I am trying to separate them to INSERT as individual records.

================Command on process page to INSERT==============================
<%

if(request.form("tm_mentee") <> "") then addMentee__varMentee = request.form("tm_mentee")

if(request.form("tm_ID") <> "") then addMentee__varMentor = request.form("tm_ID")

%>
<%

set addMentee = Server.CreateObject("ADODB.Command")
addMentee.ActiveConnection = MM_connPMDData2_DSN_STRING
addMentee.CommandText = "INSERT INTO team_mentees (mentee_ID, mentor_ID)  VALUES ('" + Replace(addMentee__varMentee, "'", "''") + "', '" + Replace(addMentee__varMentor, "'", "''") + "') "
addMentee.CommandType = 1
addMentee.CommandTimeout = 0
addMentee.Prepared = true
addMentee.Execute()

%>
===============================================================================


Is this possible?  Am I close with the "split" code segment above?

Your help is ALWAYS greatly appreciated!

Thanks so much,
ShaneStart Free Trial
[+][-]10.23.2007 at 01:29PM PDT, ID: 20134321

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.23.2007 at 02:12PM PDT, ID: 20134615

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.24.2007 at 04:10AM PDT, ID: 20137744

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Active Server Pages (ASP), Microsoft Access Database
Tags: asp, insert, vbscript, classic
Sign Up Now!
Solution Provided By: strickdd
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20081112-EE-VQP-42 / EE_QW_2_20070628