ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 9th, 2011, 11:48 AM
kbfl16 kbfl16 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2011
Posts: 2 kbfl16 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 33 sec
Reputation Power: 0
Database fields to reference Arrays in ASP

As a relative beginner to ASP, please do not scream NEWBIE too loudly when reading/answering...

I have an ASP page that displays items for a user to choose by clicking a radio button to select. Rather than manually build each item's display I have stored all the attributes of the item in an Access database and build the display dynamically.

Since I need to reference the items later I load the attributes into arrays like this:

itemrow = 0
Do While Not recordset.EOF
itemradio(itemrow) = Recordset("radname")
itemdesc(itemrow) = Recordset("Item")
itemcost(itemrow) = Recordset("itemcost")
itemvalue(itemrow) = Recordset("itemvalue")
itemimage(itemrow) = Recordset("Image")
itemrow = itemrow + 1
Recordset.MoveNext
Loop
Recordset.Close
Connection.Close

In the database radname would contain values like:
0
1
2
3
4
etc

When the form is submitted, I grab the value and store it in a field.

function get_radio_value()
{
for (var i=0; i < document.form1.group1.length; i++)
{
if (document.form1.group1[i].checked)
{
var rad_val = document.form1.group1[i].value;
document.form1.chose.value = rad_val;
return true;
}
}
}

Here is where I have issues. I am sure it is something I am doing or perhaps the type of field in the database that is causing it, but when I attempt to reference the information using the code below I constantly get a Type Mismatch no matter what type of field I set it to in the Access database.

varchose = Request.form("chose")
response.write(itemradio(varchose))


Is there some type of conversion I need to do? I have tried setting the database field to text length 2, long, integer etc.

ANY help would be so greatly appreciated!!

Thanks in advance!

Reply With Quote
  #2  
Old September 9th, 2011, 01:23 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Jun 2003
Posts: 14,235 Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 14 h 27 m 16 sec
Reputation Power: 4445
Show a snippet of the actual code and identify what line in the code is causing your error. Often it's an unexpected null value in a variable you expected to have data.

You can also look at the recordset .getrows() method to automatically build an array from a recordset.
__________________
======
Doug G
======
It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi

Reply With Quote
  #3  
Old September 9th, 2011, 03:46 PM
kbfl16 kbfl16 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2011
Posts: 2 kbfl16 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 33 sec
Reputation Power: 0
response.write(itemradio(varchose))

is the line where it is giving me the Type Mismatch, I put it in there as a way to debug and verify that the correct array item was being chosen.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Database fields to reference Arrays in ASP

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap