Splitting A multi Line Text into array??

Results 1 to 3 of 3

Thread: Splitting A multi Line Text into array??

  1. #1
    Chris T Guest

    Default Splitting A multi Line Text into array??

    Hi, Please help me...<BR><BR>I&#039;m trying to split a value returned form a textarea form field. I want to replace vbcrlf with a comma to give me a single string which i can pass to an Stored Proc to be split again and inserted into multiple records.<BR><BR>i.e<BR><BR>Value = Apples<BR> Pears<BR> Banana<BR> Peach<BR><BR>gives --&#062;&#062;&#062; Apples,Pears,Banana,Peach<BR><BR>Dim commAddCourse__year1content<BR>commAddCourse__year 1content = split(Request("year1content"),vbcrlf)<BR><BR>What will this return? Is it right?? I think im missing stuff<BR><BR>Thanks in Advance <BR><BR>CeeTee<BR> <BR>

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default Replace with a ,

    replace(Request("year1content"),vbcrlf, ",")<BR><BR><BR>but you do know this is a wasted step right<BR><BR><BR>you can always split the string on vbCrLf also you know.<BR><BR><BR>

  3. #3
    Chris T Guest

    Default Doh! Multiple Child Records.....

    Thanks,I just realised what a stupid question that was !!!<BR><BR>What I really want to do is take the string "apples,oranges,bananas......" and create a record for each one of these in a two field table using my stored proc.<BR><BR>The first field of the table gets its value from the @@IDENTITY<BR><BR>so from "apples,pears,oranges......."<BR><BR>i want in my table<BR><BR>ID Content<BR>34 apples<BR>34 pears<BR>34 oranges <BR><BR>Etc. Any Ideas anyone???? Maybe more of a DB Stored Proc Question but im sure someone will know.<BR><BR>Cut down version of StoredProc &#062;&#062;<BR><BR>CREATE PROCEDURE spAddCourse<BR><BR>SET @CourseID = @@IDENTITY<BR><BR>--insert into year1 Table<BR>--this is where I want multiple records inserted from a delimited string<BR><BR>INSERT INTO Year1 (CourseID, Content)<BR><BR>VALUES (@CourseID, @year1content) <BR><BR>Return<BR><BR><BR><BR><BR><BR>Cheers CeeTee.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts