473,245 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,245 software developers and data experts.

split question, I guess

Not really sure what the problem is, perhaps I am using split wrong.

Page should get form fields form previous page and some of them will go into
a tabel called Personal. Other items, to resolve a many-to-many
relationship, will go into a table called PersonalPeople, which consists of
2 fields: the PK's from the People table and the Perosnal table. I decided
to have the 30 or so checkboxes on the first page all have the same name, as
they are built dynamcially from the People table. If you check boxes
numbered 1, 6, and 19, then request.form("People") returns a string of
(1,6,19)

All of the above has been confirmed to work using Response.write.

Now, I want to pull each value from the above comma-delimted string and
insert them into the PersonalPeople table. I had already obtained the
PersonalID (the PK of the Personal Table). so I built a loop which would
take the values out of the comma-delimted string, and insert them along with
the PersonalID

Can't seem to make it work. I've spent way too many hours on this one
problem. Any help would be appreciated. Here's the code that's relevant,
with a couple of quick comments at the end. This code is from the 2nd page,
the one that is after the form is submitted.
:

--------------------------
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Inetpub\wwwroot\Grace\Shape.mdb;User Id=admin;Password=;"

Set objConnection = Server.CreateObject("ADODB.Connection")
objConnection.ConnectionString = strConnection
objConnection.Open

'this is the stuff that goes into personal table, but also need to add
things in
'combo tables, like gift, people, area,

strSQL = "INSERT INTO Personal[blah,blah,blah]
strSQL = strSQL & "VALUES [blah,blah,blah]
objConnection.Execute strSQL

'get the PersonalID (PK) that was just inserted
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&"') "
response.write strSQL
response.end
objConnection.Execute strSQL
next
end if

===================================

Thing is, I put a response.write after that --if len(strPeopleID)>0 then--
line, and it became apparent that I was, in fact, falling into the IF
statement correctly. But for some reason, the next response.write doesn't
yield anything. So I guess I am doing the split thing wrong. I tried doing a
response.write arrPeople, but it threw an error. So I can't see where I am
going wrong.

Please help. I'll be glad to send complete code if asked.


Jul 19 '05 #1
2 2190

"middletree" <mi********@htomail.com> wrote in message
news:up**************@TK2MSFTNGP10.phx.gbl...
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
Jul 19 '05 #2
WOW! Very helpful tips. Thanks!
"Ray at <%=sLocation%>" <myFirstNameATlane34dotKOMM> wrote in message
news:#X*************@tk2msftngp13.phx.gbl...

"middletree" <mi********@htomail.com> wrote in message
news:up**************@TK2MSFTNGP10.phx.gbl...
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

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Luka Milkovic | last post by:
Hello, I have a little problem and although it's little it's extremely difficult for me to describe it, but I'll try. I have written a program which extracts certain portions of my received...
9
by: Will McGugan | last post by:
Hi, I'm curious about the behaviour of the str.split() when applied to empty strings. "".split() returns an empty list, however.. "".split("*") returns a list containing one empty string. ...
8
by: uc_sk | last post by:
Hello All I am a newbie to PERL language...If i have a file with data of form abcd 4 {1,2,3} 3 lmn- 3 {12,18,19,22} 4 then i can read them as... ($list $listTotal $set $noElements) = split /...
9
by: martin | last post by:
Hi, a very newbie question. How do I split the adress and number to 2 variables? ex. "Kingsroad 347" = variabel1 = "Kingsroad" variabel2 = "347" Ill guess i have to search the string from...
9
by: Steve Jorgensen | last post by:
Hi all, I'm working on the schema for a database that must represent data about stock & bond funds over time. My connundrum is that, for any of several dimension fields, including the fund name...
14
by: Ron | last post by:
Hello, I am trying to parse a string on the newline char. I guess vbCrLf is a string constant. How can I parse my string - data - on the newline char? .... data += ASCII.GetString(buffer, 0,...
7
by: Mark A | last post by:
If server 01 running HADR in the primary role crashes, and the DBA does a HADR takeover by force on the 02 server to switch roles, then the 02 server is now the primary. What happens when the...
24
by: garyusenet | last post by:
I'm working on a data file and can't find any common delimmiters in the file to indicate the end of one row of data and the start of the next. Rows are not on individual lines but run accross...
3
cwoozy
by: cwoozy | last post by:
I'm writing a program that has the user input their name, then converts their name to a "numeric value" (basically, take the ASCII value of all of the characters and add them together). I think I...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.