split not working

M

middletree

Sorry for starting a new thread, but the original was 24 hours ago, and I am
afraid it won't get seen.

In the original, Ray advised me to change

if len(strPeopleID)>0 then

arrPeople = SPLIT(strPeople,",")
for x=lbound(arrPeople) to ubound(arrPeople)
strSQL = "INSERT into PersonalPeople(PersonalID,PeopleID) "
strSQL = strSQL & "VALUES('"&strPersonalID&"','"&strPeopleID(x)&"')"
response.write strSQL
response.end
objConnection.Execute strSQL
next
end if

to

if len(strPeopleID)>0 then

arrPeople = SPLIT(strPeople,",")
for x=lbound(arrPeople) to ubound(arrPeople)
strSQL = "INSERT into PersonalPeople(PersonalID,PeopleID) "
strSQL = strSQL & "VALUES('"&strPersonalID&"','"&arrPeople(x)&"')"
response.write strSQL
response.end
objConnection.Execute strSQL
next
end if

(the difference is in the VALUES line, last part)

I did the change, but same result. I'm gettiung pretty desperate, as I have
spent countless hours on this one thing. Any help would be appreciated.

Below is the entire original description of the problem:



set rs = objConnection.execute("select MAX(PersonalID) from Personal")
'response.write "New ID was " & rs(0)
strPersonalID = rs(0)

objConnection.Close
Set objConnection = nothing

'these three will pull from the checkboxes, should give a string
Set objConnection = Server.CreateObject("ADODB.Connection")
objConnection.ConnectionString = strConnection
objConnection.Open

strPeopleID = request.form("People")
if len(strPeopleID)>0 then
arrPeople = SPLIT(strPeople,",")
for x=lbound(arrPeople) to ubound(arrPeople)
strSQL = "INSERT into PersonalPeople(PersonalID,PeopleID) "
strSQL = strSQL & "VALUES('"&strPersonalID&"','"&strPeopleID&"')"


I think you'd want to insert arrPeople(x) there instead of strPeopleID.
strPeopleID will equal something like "2, 3, 6, 8, 32, 49"

Also, when you Split() strPeopleID, split by ", " instead of "," or
replace(strPeopleID, ", ", ",") before splitting. There are spaces after
the commas.

Also, is PeopleID a text type column? You have it delimited with '.

Another thing is that you should put spaces after (at least) the &
concatenation operator. If you don't, you'll run into issues if you have a
variable name that starts with an "h" as &h indicates a hex value is to
follow.

Ray at home
 
M

middletree

I should add that I did end up following through on Ray's advice about
spaces and apostrophes. But the bottom line is that it never gets that far.
I know this because I put that response.write part in there, and it doesn't
write anything. Therefore, it doesn't get to that point.

I ran what should have been the right query in Access itself:

INSERT into PersonalPeople(PersonalID,PeopleID)
VALUES(1,1)

And it worked fine. But because I can't get response.write to do anything, I
can't tell if that's the query I am sending to the database.
 
R

Ray at

What does this do?


if len(strPeopleID)>0 then

arrPeople = SPLIT(strPeople,",")
for x=lbound(arrPeople) to ubound(arrPeople)
strSQL = "INSERT into PersonalPeople(PersonalID,PeopleID) "
strSQL = strSQL & "VALUES('"&strPersonalID&"','"&arrPeople(x)&"')"
response.write strSQL
response.end
objConnection.Execute strSQL
next
ELSE
RESPONSE.WRITE "LEN OF STRPEOPLEID <= 0. DAMN!"
end if

RESPONSE.END

Ray at home
 
M

middletree

Unfortunately, the cycle I go through is this: After my wife and kids get to
bed, I get to start on this project, around 10:00. I work on it for an hour,
then get stuck. I post a question to the NG, but then I am so sleepy that I
log off and hit the hay.

The next morning, I see the reply, then have to wait till 10:00 tonight to
try out the suggestions.

Very frustrating.

I do some ASP here at work during the day, but wouldn't feel right doing my
side project at work.

I'll try your suggestion tonight, and let you know what I see.

thanks
 
R

Ray at

middletree said:
Unfortunately, the cycle I go through is this: After my wife and kids get to
bed, I get to start on this project, around 10:00. I work on it for an hour,
then get stuck. I post a question to the NG, but then I am so sleepy that I
log off and hit the hay.
The next morning, I see the reply, then have to wait till 10:00 tonight to
try out the suggestions.

Very frustrating.

Yeah, I know. I feel bad for people who don't live in or around a US time
zone, because while I realize that the Internet stretches beyond the US, I
think it's safe to assume that 70% of the questions and answers come from
within the US time zones (whether the person is in Canada, US, or whatever).
I do some ASP here at work during the day, but wouldn't feel right doing my
side project at work.

You probably have a coworker who sleeps all day, so use that as your
self-rationalization that it would be okay for you to work on your side
project at work. Besides, if your job involves any sort of web development,
by working on side projects, you are increasing your knowledge and
experience. So, you're working. That's what I tell myself when I'm sitting
here reading nascar.com or something. I'm researching user interfaces.
I'll try your suggestion tonight, and let you know what I see.

I stay up late. :]

Ray at work
 
M

middletree

Ray at said:
So, you're working. That's what I tell myself when I'm sitting
here reading nascar.com or something. I'm researching user interfaces.

LOL!
I'll try your suggestion tonight, and let you know what I see.

I stay up late. :]

'preciate it.
 
R

Roger

middletree said:
Ray at said:
So, you're working. That's what I tell myself when I'm sitting
here reading nascar.com or something. I'm researching user interfaces.

LOL!
I'll try your suggestion tonight, and let you know what I see.

I stay up late. :]

'preciate it.


change
if len(strPeopleID)>0 then

to
if len(strPeopleID)<> "" then
 
B

Bob Barrows

Roger said:
change
if len(strPeopleID)>0 then

to
if len(strPeopleID)<> "" then

Why? The len function returns a number. It will never be equal to ""

Bob Barrows
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top