473,698 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("P eople") 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=Micro soft.Jet.OLEDB. 4.0;Data
Source=C:\Inetp ub\wwwroot\Grac e\Shape.mdb;Use r Id=admin;Passwo rd=;"

Set objConnection = Server.CreateOb ject("ADODB.Con nection")
objConnection.C onnectionString = strConnection
objConnection.O pen

'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.E xecute strSQL

'get the PersonalID (PK) that was just inserted
set rs = objConnection.e xecute("select MAX(PersonalID) from Personal")
'response.write "New ID was " & rs(0)
strPersonalID = rs(0)

objConnection.C lose
Set objConnection = nothing

'these three will pull from the checkboxes, should give a string
Set objConnection = Server.CreateOb ject("ADODB.Con nection")
objConnection.C onnectionString = strConnection
objConnection.O pen

strPeopleID = request.form("P eople")
if len(strPeopleID )>0 then
arrPeople = SPLIT(strPeople ,",")
for x=lbound(arrPeo ple) to ubound(arrPeopl e)
strSQL = "INSERT into PersonalPeople( PersonalID,Peop leID) "
strSQL = strSQL & "VALUES('"&strP ersonalID&"','" &strPeopleID&"' )"
response.write strSQL
response.end
objConnection.E xecute 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 2217

"middletree " <mi********@hto mail.com> wrote in message
news:up******** ******@TK2MSFTN GP10.phx.gbl...
set rs = objConnection.e xecute("select MAX(PersonalID) from Personal")
'response.write "New ID was " & rs(0)
strPersonalID = rs(0)

objConnection.C lose
Set objConnection = nothing

'these three will pull from the checkboxes, should give a string
Set objConnection = Server.CreateOb ject("ADODB.Con nection")
objConnection.C onnectionString = strConnection
objConnection.O pen

strPeopleID = request.form("P eople")
if len(strPeopleID )>0 then
arrPeople = SPLIT(strPeople ,",")
for x=lbound(arrPeo ple) to ubound(arrPeopl e)
strSQL = "INSERT into PersonalPeople( PersonalID,Peop leID) "
strSQL = strSQL & "VALUES('"&strP ersonalID&"','" &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(strPeop leID, ", ", ",") 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% >" <myFirstNameATl ane34dotKOMM> wrote in message
news:#X******** *****@tk2msftng p13.phx.gbl...

"middletree " <mi********@hto mail.com> wrote in message
news:up******** ******@TK2MSFTN GP10.phx.gbl...
set rs = objConnection.e xecute("select MAX(PersonalID) from Personal")
'response.write "New ID was " & rs(0)
strPersonalID = rs(0)

objConnection.C lose
Set objConnection = nothing

'these three will pull from the checkboxes, should give a string
Set objConnection = Server.CreateOb ject("ADODB.Con nection")
objConnection.C onnectionString = strConnection
objConnection.O pen

strPeopleID = request.form("P eople")
if len(strPeopleID )>0 then
arrPeople = SPLIT(strPeople ,",")
for x=lbound(arrPeo ple) to ubound(arrPeopl e)
strSQL = "INSERT into PersonalPeople( PersonalID,Peop leID) "
strSQL = strSQL & "VALUES('"&strP ersonalID&"','" &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(strPeop leID, ", ", ",") 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
2141
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 e-mail. The content of the e-mail is actually predictable, it has one very long list of numbers, something looking like this:
9
4346
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. I would have expected the second example to have also returned an empty
8
2094
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 / / But if i have a dataset of the form:
9
1768
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 left to right after first apperence of a number, but how do i do that? Regards Martin
9
3726
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 itself, the dimension may be represented in different ways over time, and may split or combine from one period to the next. When querying from the database for an arbitrary time period, I need the data to be rolled up to the smallest extent...
14
34960
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, bytesRead) .... Dim parts() As String = data.Split(vbCrLf)
7
10588
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 Server 01 is brought back up? It still thinks it is the primary because that was its role when it crashed and it does not know about the takeover by force command that was issued. Does the 01 server check the 02 server to see what role they are in...
24
4823
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 multiple lines. It would appear though that every distinct set of data starts with a 'code' that is always the 25 characters long. The text is variable however. Assuming i've read the contents of the file into the string myfile, how do i split my...
3
1387
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 know just about everything I need to write my program, except for one thing: Since spaces count as 32, I would like to eliminate them from the inputted string. My first guess was to just string.split and then concatenate the two split strings, but...
0
8685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2342
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.