Re: Can you use dynamic data in a request form

From: Bob Barrows (reb01501_at_NOyahoo.SPAMcom)
Date: 02/14/04


Date: Sat, 14 Feb 2004 15:44:03 -0500

bateman wrote:
> Hi, I am am trying to write some code to perform a INSERT in SQL
> table using a loop. What would be great is a way of dynamically
> entering in data in a requaest.form
> ie the final code should look something like:
>
>
> if Request.Form("type1") = "1" then
>
>
> where the 1 in "type1" is dynamic so the code would look something
> like
>
>
> Request.Form("type" & Rs.("fld_type_id") & ") = "1" then
>
> But not sure how to form this or whether it would work, anyone have
> any idea?

Of course it would work. All you need inside the parntheses is a string
containing the name of the variable. How that string is built is irrelevant.

sVar = "type" & Rs.("fld_type_id")
if Request.Form(sVar) = "1" then

Or, if you want to fly by the seat of your pants:
if Request.Form("type" & Rs.("fld_type_id") ) = "1" then

HTH,
Bob Barrows

-- 
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Relevant Pages

  • Re: Dynamic SQL Execution
    ... the string: ... > @rOUT OUTPUT ... > SQL Server MVP ... >> In a cursor, as I loop through, I create a dynamic SQL each time. ...
    (microsoft.public.sqlserver.programming)
  • Re: Slow performance with SQL and stmt.executeUpdate()
    ... method call, using SQL insert. ... Statement stmt = conn.createStatement; ... String phone = md.getPhone; ... after the loop is finished. ...
    (comp.lang.java.databases)
  • Re: Loop through names of controls
    ... Didn't scroll down to the string of the sql. ... thought he was having trouble getting an object in his loop. ... >> I'm running some SQL to insert the value in each control into a table. ...
    (microsoft.public.access.formscoding)
  • Newbee - how to loop through table and delete unwanted records
    ... Note it is always the 1st record of the new groupNo ... So I have decided to try to loop though the table and compare the ... Then the next line of code runs the SQL delete string I made in step 1. ...
    (microsoft.public.access.gettingstarted)
  • Re: Connect directly to SQL server to retrieve rows from a Table/View
    ... I currently have a SQL View that queries a table containing user data ... adds/deletes users in Active directory if their attributes are ... Just open an ADO recordset on the view and loop through it ... This email account is my spam trap so I ...
    (microsoft.public.scripting.vbscript)