?
Solved

Simple question : How can I replace array variable names to my database field names?

Posted on 2003-10-30
3
Medium Priority
?
142 Views
Last Modified: 2010-04-06
I am using 1 radio button to get 3 values by splitting the values so I get the Product name, reference and the amount, like the code below:

<% Dim arrProduct
   arrProduct = Split (Request.Form ("radio1") , ",") %>
                                          Product amount : <%= arrProduct (0) %> <br>
Product item : <%= arrProduct (1) %> <br>
Reference : <%= arrProduct (2) %>

How can I replace the variable names to match my database fields?
The array corresponding to the database field is as follows:

<%= arrProduct (0) to amount
<%= arrProduct (1) to item
<%= arrProduct (2) to reference

My SQL statement is:

SQLstr      = "INSERT INTO epayment(amount, item, reference, name, designation, regNo, email, company, address, telephone, Date, fax) VALUES('" & _
0
Comment
Question by:zamorin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Expert Comment

by:DelTreme
ID: 9656761
Try something like this:

Dim arrRecName(100)
Dim arrRecValue(100)

For i = 0 to recSet.Field.Count - 1
  arrRecName(i) = recSet.Fields(i).Name
  arrRecValue(i) = recSet(i)

  %><%=arrRecName(i)%> = <%=arrRecValue(i)%><br><%

Next

0
 
LVL 3

Expert Comment

by:DelTreme
ID: 9656777
If that doesn't satisfy you: There's no way to convert items from a database to a variable name.
0
 
LVL 15

Accepted Solution

by:
VincentPuglia earned 120 total points
ID: 9657964
+Hi Zamorin,

I'm not certain what you mean, nor am I an asper, but if your Split creates an array (3 times longer than number of records)  and you wish to place that array within a javascript array, the following should work:

<SCRIPT TYPE="text/javascript">
<!--
var arrProduct = new Array();
var items = references = products = new Array();
var arrProduct = <% =Split(Request.Form("radio1"),",") %>
for ( var i = 0; i < arrProduct.length; i++)
   items[i] = arrProduct[i++];
  references[i] = arrProduct[i++];
  products[i] = arrProducts[i++];
// -->
</SCRIPT>

Vinny
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to count occurrences of each item in an array.

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question