?
Solved

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

Posted on 2003-10-30
3
Medium Priority
?
141 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

777 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