Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Request.form usage not clear

Reply
Thread Tools

Request.form usage not clear

 
 
Jack
Guest
Posts: n/a
 
      03-24-2005
Hi,
I am trying to get a thorough understanding of a code where a addition or
deletion of records can be done from a list of records. For addition part of
the form, data is being obtained from set of input boxes.
The following is the code being used:

If Len(Request.Form("ID_0"))>0 Then
AuthorID=Request.Form("ID_0")
FName=Request.Form("fName_0")
LName=Request.Form("lName_0")

' SQL will break on names like O'Leary
' if single quotes are not doubled.
LName=Replace(LName,"'","''")

Phone=Request.Form("Phone_0")
Address=Request.Form("Address_0")
City=Request.Form("City_0")
State=Request.Form("State_0")

' Create the UPDATE SQL Statement
sql = " INSERT INTO Authors (au_id, au_fName, "
sql = sql & "au_lName, phone, address, city, state)"
sql = sql & " VALUES('" & AuthorID & "','" & FName
sql = sql & "','" & LName & "','" & Phone
sql = sql & "','" & Address & "','" & City
sql = sql & "','" & State & "')"

' Execute the INSERT SQL
cnnPubs.Execute sql
intCount=1
End if
I am not clear where the 0 suffix is coming from in the following:
AuthorID=Request.Form("ID_0")
FName=Request.Form("fName_0")

Thanks for any help.

 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      03-24-2005
=?Utf-8?B?SmFjaw==?= wrote on 25 mrt 2005 in
microsoft.public.inetserver.asp.general:

> Hi,
> I am trying to get a thorough understanding of a code where a addition
> or deletion of records can be done from a list of records. For
> addition part of the form, data is being obtained from set of input
> boxes. The following is the code being used:
>
> If Len(Request.Form("ID_0"))>0 Then
> AuthorID=Request.Form("ID_0")
> FName=Request.Form("fName_0")
> LName=Request.Form("lName_0")
>
> ' SQL will break on names like O'Leary
> ' if single quotes are not doubled.
> LName=Replace(LName,"'","''")
>
> Phone=Request.Form("Phone_0")
> Address=Request.Form("Address_0")
> City=Request.Form("City_0")
> State=Request.Form("State_0")
>
> ' Create the UPDATE SQL Statement
> sql = " INSERT INTO Authors (au_id, au_fName, "
> sql = sql & "au_lName, phone, address, city, state)"
> sql = sql & " VALUES('" & AuthorID & "','" & FName
> sql = sql & "','" & LName & "','" & Phone
> sql = sql & "','" & Address & "','" & City
> sql = sql & "','" & State & "')"
>
> ' Execute the INSERT SQL
> cnnPubs.Execute sql
> intCount=1
> End if
> I am not clear where the 0 suffix is coming from in the following:
> AuthorID=Request.Form("ID_0")
> FName=Request.Form("fName_0")


That is what you typed in, I presume.

do you have any other suggestions?


--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

 
Reply With Quote
 
 
 
 
Jack
Guest
Posts: n/a
 
      03-24-2005
Thanks for pointing that out. At a later part of the code, there is indeed
reference to the 0s. Regards.

"Evertjan." wrote:

> =?Utf-8?B?SmFjaw==?= wrote on 25 mrt 2005 in
> microsoft.public.inetserver.asp.general:
>
> > Hi,
> > I am trying to get a thorough understanding of a code where a addition
> > or deletion of records can be done from a list of records. For
> > addition part of the form, data is being obtained from set of input
> > boxes. The following is the code being used:
> >
> > If Len(Request.Form("ID_0"))>0 Then
> > AuthorID=Request.Form("ID_0")
> > FName=Request.Form("fName_0")
> > LName=Request.Form("lName_0")
> >
> > ' SQL will break on names like O'Leary
> > ' if single quotes are not doubled.
> > LName=Replace(LName,"'","''")
> >
> > Phone=Request.Form("Phone_0")
> > Address=Request.Form("Address_0")
> > City=Request.Form("City_0")
> > State=Request.Form("State_0")
> >
> > ' Create the UPDATE SQL Statement
> > sql = " INSERT INTO Authors (au_id, au_fName, "
> > sql = sql & "au_lName, phone, address, city, state)"
> > sql = sql & " VALUES('" & AuthorID & "','" & FName
> > sql = sql & "','" & LName & "','" & Phone
> > sql = sql & "','" & Address & "','" & City
> > sql = sql & "','" & State & "')"
> >
> > ' Execute the INSERT SQL
> > cnnPubs.Execute sql
> > intCount=1
> > End if
> > I am not clear where the 0 suffix is coming from in the following:
> > AuthorID=Request.Form("ID_0")
> > FName=Request.Form("fName_0")

>
> That is what you typed in, I presume.
>
> do you have any other suggestions?
>
>
> --
> Evertjan.
> The Netherlands.
> (Replace all crosses with dots in my emailaddress)
>
>

 
Reply With Quote
 
Mark Schupp
Guest
Posts: n/a
 
      03-25-2005
Appending an index number to the field name is one way of keeping track of
multiple records on a single form.
For example:

First author on form would have: ID_0, fname_0, lname_0 ...
Second author: id_1, fname_1, lname_1

And so on. Have a look at the code that generates the form and you will
probably find a loop that creates each set of form fields.

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


"Jack" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
> I am trying to get a thorough understanding of a code where a addition or
> deletion of records can be done from a list of records. For addition part
> of
> the form, data is being obtained from set of input boxes.
> The following is the code being used:
>
> If Len(Request.Form("ID_0"))>0 Then
> AuthorID=Request.Form("ID_0")
> FName=Request.Form("fName_0")
> LName=Request.Form("lName_0")
>
> ' SQL will break on names like O'Leary
> ' if single quotes are not doubled.
> LName=Replace(LName,"'","''")
>
> Phone=Request.Form("Phone_0")
> Address=Request.Form("Address_0")
> City=Request.Form("City_0")
> State=Request.Form("State_0")
>
> ' Create the UPDATE SQL Statement
> sql = " INSERT INTO Authors (au_id, au_fName, "
> sql = sql & "au_lName, phone, address, city, state)"
> sql = sql & " VALUES('" & AuthorID & "','" & FName
> sql = sql & "','" & LName & "','" & Phone
> sql = sql & "','" & Address & "','" & City
> sql = sql & "','" & State & "')"
>
> ' Execute the INSERT SQL
> cnnPubs.Execute sql
> intCount=1
> End if
> I am not clear where the 0 suffix is coming from in the following:
> AuthorID=Request.Form("ID_0")
> FName=Request.Form("fName_0")
>
> Thanks for any help.
>




 
Reply With Quote
 
Jack
Guest
Posts: n/a
 
      03-25-2005
Thanks for the clarity of the concept Mark. I saw later how the code keeps
track of multiple records in a single form. Is there any way of handling this
kind of problems? Just curious. Regards.

"Mark Schupp" wrote:

> Appending an index number to the field name is one way of keeping track of
> multiple records on a single form.
> For example:
>
> First author on form would have: ID_0, fname_0, lname_0 ...
> Second author: id_1, fname_1, lname_1
>
> And so on. Have a look at the code that generates the form and you will
> probably find a loop that creates each set of form fields.
>
> --
> --Mark Schupp
> Head of Development
> Integrity eLearning
> www.ielearning.com
>
>
> "Jack" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi,
> > I am trying to get a thorough understanding of a code where a addition or
> > deletion of records can be done from a list of records. For addition part
> > of
> > the form, data is being obtained from set of input boxes.
> > The following is the code being used:
> >
> > If Len(Request.Form("ID_0"))>0 Then
> > AuthorID=Request.Form("ID_0")
> > FName=Request.Form("fName_0")
> > LName=Request.Form("lName_0")
> >
> > ' SQL will break on names like O'Leary
> > ' if single quotes are not doubled.
> > LName=Replace(LName,"'","''")
> >
> > Phone=Request.Form("Phone_0")
> > Address=Request.Form("Address_0")
> > City=Request.Form("City_0")
> > State=Request.Form("State_0")
> >
> > ' Create the UPDATE SQL Statement
> > sql = " INSERT INTO Authors (au_id, au_fName, "
> > sql = sql & "au_lName, phone, address, city, state)"
> > sql = sql & " VALUES('" & AuthorID & "','" & FName
> > sql = sql & "','" & LName & "','" & Phone
> > sql = sql & "','" & Address & "','" & City
> > sql = sql & "','" & State & "')"
> >
> > ' Execute the INSERT SQL
> > cnnPubs.Execute sql
> > intCount=1
> > End if
> > I am not clear where the 0 suffix is coming from in the following:
> > AuthorID=Request.Form("ID_0")
> > FName=Request.Form("fName_0")
> >
> > Thanks for any help.
> >

>
>
>
>

 
Reply With Quote
 
Mark Schupp
Guest
Posts: n/a
 
      03-26-2005
do you mean any "other" way for that kind of problem?

If you name all of the fields of the same type the same name (ie: "id"
instead of "id_0", "id_1", ...) then you can use array notation on the
server to extract the data. Or you can use the split function to break of
the field data into individual records (when field names are repeated the
data is sent in a comma separated string).

Form:

<input name="id" ....
<input name="lname" ...
<input name="id" ....
<input name="lname" ...
<input name="id" ....
<input name="lname" ...

Script
For i = 0 to Request.Form("id").Count
id = Request.Form("id")(i)
lname=Request.Form("lname")(i)

....

Next

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

"Jack" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks for the clarity of the concept Mark. I saw later how the code keeps
> track of multiple records in a single form. Is there any way of handling
> this
> kind of problems? Just curious. Regards.
>
> "Mark Schupp" wrote:
>
>> Appending an index number to the field name is one way of keeping track
>> of
>> multiple records on a single form.
>> For example:
>>
>> First author on form would have: ID_0, fname_0, lname_0 ...
>> Second author: id_1, fname_1, lname_1
>>
>> And so on. Have a look at the code that generates the form and you will
>> probably find a loop that creates each set of form fields.
>>
>> --
>> --Mark Schupp
>> Head of Development
>> Integrity eLearning
>> www.ielearning.com
>>
>>
>> "Jack" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > Hi,
>> > I am trying to get a thorough understanding of a code where a addition
>> > or
>> > deletion of records can be done from a list of records. For addition
>> > part
>> > of
>> > the form, data is being obtained from set of input boxes.
>> > The following is the code being used:
>> >
>> > If Len(Request.Form("ID_0"))>0 Then
>> > AuthorID=Request.Form("ID_0")
>> > FName=Request.Form("fName_0")
>> > LName=Request.Form("lName_0")
>> >
>> > ' SQL will break on names like O'Leary
>> > ' if single quotes are not doubled.
>> > LName=Replace(LName,"'","''")
>> >
>> > Phone=Request.Form("Phone_0")
>> > Address=Request.Form("Address_0")
>> > City=Request.Form("City_0")
>> > State=Request.Form("State_0")
>> >
>> > ' Create the UPDATE SQL Statement
>> > sql = " INSERT INTO Authors (au_id, au_fName, "
>> > sql = sql & "au_lName, phone, address, city, state)"
>> > sql = sql & " VALUES('" & AuthorID & "','" & FName
>> > sql = sql & "','" & LName & "','" & Phone
>> > sql = sql & "','" & Address & "','" & City
>> > sql = sql & "','" & State & "')"
>> >
>> > ' Execute the INSERT SQL
>> > cnnPubs.Execute sql
>> > intCount=1
>> > End if
>> > I am not clear where the 0 suffix is coming from in the following:
>> > AuthorID=Request.Form("ID_0")
>> > FName=Request.Form("fName_0")
>> >
>> > Thanks for any help.
>> >

>>
>>
>>
>>



 
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
Response.Clear() doesn't clear David ASP .Net 2 01-31-2008 08:32 PM
binascii.unhexlify ... not clear about usage, and output Vishal Python 6 07-12-2007 12:21 AM
Unrecognized element 'add' after <clear></clear> InvalidLastName ASP .Net Web Services 3 03-06-2007 03:07 AM
Telstra Clear's Cable Usage Meter again Jonno NZ Computing 16 03-03-2006 11:18 PM
Need help on memory usage VS PF usage metfan Java 2 10-21-2003 01:58 PM



Advertisments