Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Parse record, convert to session variables

Reply
Thread Tools

Parse record, convert to session variables

 
 
Brandon
Guest
Posts: n/a
 
      06-09-2004
Greetings,

I have a database with records that contain data like the following:

"vendor" - "phone number" - "city", "state" "problem."

For example:
xyzcompany - 800-123-4567 - new york, ny tp.

The line above is one record, the company names will differ (but are
limited to a dozen), the format of the number will always be with a dash
seperating the area code and number, the city and state will be in
place, and the problem will be a two letter code followed by a period.

I need to be able to parse that record into seperate session variables
such as Session("vendor"), Session("area_code"), Session("number"), and
on with the city, state, and problem.

What is the best method to use in VBScript/ASP to break this record down
into pieces?

I appreciate any help you can give.

Thanks,
Brandon


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
 
Alan Howard
Guest
Posts: n/a
 
      06-09-2004
You say the data below is a record - assuming that you are still able to
address the individual fields, use something like:

For Each objField In objRS.Fields

Session (CStr(objField.Name)) = CStr(objField.Value)

Next

- or are you asking how to split a single string??


"Brandon" <bdreilingATmac.com> wrote in message
news:%(E-Mail Removed)...
> Greetings,
>
> I have a database with records that contain data like the following:
>
> "vendor" - "phone number" - "city", "state" "problem."
>
> For example:
> xyzcompany - 800-123-4567 - new york, ny tp.
>
> The line above is one record, the company names will differ (but are
> limited to a dozen), the format of the number will always be with a dash
> seperating the area code and number, the city and state will be in
> place, and the problem will be a two letter code followed by a period.
>
> I need to be able to parse that record into seperate session variables
> such as Session("vendor"), Session("area_code"), Session("number"), and
> on with the city, state, and problem.
>
> What is the best method to use in VBScript/ASP to break this record down
> into pieces?
>
> I appreciate any help you can give.
>
> Thanks,
> Brandon
>
>
> *** Sent via Devdex http://www.devdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
 
 
 
Dave Anderson
Guest
Posts: n/a
 
      06-09-2004
Alan Howard wrote:
>
> For Each objField In objRS.Fields
>
> Session (CStr(objField.Name)) = CStr(objField.Value)
>
> Next


CStr is unnecessary with [Name]...
http://msdn.microsoft.com/library/en.../mdproname.asp


....and possibly unwanted with [Value], depending on the data type.



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.


 
Reply With Quote
 
Mark Schupp
Guest
Posts: n/a
 
      06-09-2004
If your format and delimiters are fixed (unchanging) then

a1 = split( strRecord, ",")
a2 = split( a1(0), "-")
a3 = split( a1(1), " ")

vendor = a2(0)
areacode = a2(1)
phonenum = a2(2) & "-" a2(3)
city = a2(4)
state = a3(0)
prob = a3(1)


--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com


"Brandon" <bdreilingATmac.com> wrote in message
news:%(E-Mail Removed)...
> Greetings,
>
> I have a database with records that contain data like the following:
>
> "vendor" - "phone number" - "city", "state" "problem."
>
> For example:
> xyzcompany - 800-123-4567 - new york, ny tp.
>
> The line above is one record, the company names will differ (but are
> limited to a dozen), the format of the number will always be with a dash
> seperating the area code and number, the city and state will be in
> place, and the problem will be a two letter code followed by a period.
>
> I need to be able to parse that record into seperate session variables
> such as Session("vendor"), Session("area_code"), Session("number"), and
> on with the city, state, and problem.
>
> What is the best method to use in VBScript/ASP to break this record down
> into pieces?
>
> I appreciate any help you can give.
>
> Thanks,
> Brandon
>
>
> *** Sent via Devdex http://www.devdex.com ***
> Don't just participate in USENET...get rewarded for it!



 
Reply With Quote
 
Alan Howard
Guest
Posts: n/a
 
      06-09-2004
> CStr is unnecessary with [Name]...
> ...and possibly unwanted with [Value], depending on the data type.


Habit - easier than second-guessing variant sub-types.

Alan

"Dave Anderson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Alan Howard wrote:
> >
> > For Each objField In objRS.Fields
> >
> > Session (CStr(objField.Name)) = CStr(objField.Value)
> >
> > Next

>
> CStr is unnecessary with [Name]...
> http://msdn.microsoft.com/library/en.../mdproname.asp
>
>
> ...and possibly unwanted with [Value], depending on the data type.
>
>
>
> --
> Dave Anderson
>
> Unsolicited commercial email will be read at a cost of $500 per message.

Use
> of this email address implies consent to these terms. Please do not

contact
> me directly or ask me to contact you directly for assistance. If your
> question is worth asking, it's worth posting.
>
>



 
Reply With Quote
 
Brandon
Guest
Posts: n/a
 
      06-10-2004
Thanks, that did the trick!

Brandon
_________________________________________

If your format and delimiters are fixed (unchanging) then

a1 = split( strRecord, ",")
a2 = split( a1(0), "-")
a3 = split( a1(1), " ")

vendor = a2(0)
areacode = a2(1)
phonenum = a2(2) & "-" a2(3)
city = a2(4)
state = a3(0)
prob = a3(1)


--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Put variables into member variables or function variables? tjumail@gmail.com C++ 9 03-23-2008 04:03 PM
optparse: parse v. parse! ?? 7stud -- Ruby 3 02-20-2008 05:20 AM
convert from static variables to session nicepg ASP .Net 1 06-26-2006 05:26 AM
How to parse a string like C program parse the command line string? linzhenhua1205@163.com C Programming 19 03-15-2005 07:41 PM
Do I need to Convert with Convert.ToInt32(session("myNumber")) ? Andreas Klemt ASP .Net 1 07-23-2003 02:59 PM



Advertisments