DeveloperBarn Forums

DeveloperBarn

Programming & IT forum

retreive DB values into a DD box

This is a discussion on retreive DB values into a DD box within the ASP Development forums, part of the Programming & Scripting category; Code: <fieldset style="padding: 2; width:600px; height:53"> <legend><font color="#0000FF"><b>Talent Review</b></font></legend> <font face="Arial"> <font size="2">&nbsp; 4</font><font size="2" face="Arial">) High Potential:</font> <select name="High_Potential" ...

Go Back   DeveloperBarn Forums > Programming & Scripting > ASP Development

  #1  
Old March 30th, 2009, 09:16 AM
Centurion's Avatar
Barn Enthusiast
 
Join Date: Dec 2008
Posts: 352
Rep Power: 2
Centurion is on a distinguished road
Default retreive DB values into a DD box

Code:
	<fieldset style="padding: 2; width:600px; height:53">
	<legend><font color="#0000FF"><b>Talent Review</b></font></legend>
	<font face="Arial">
	<font size="2">&nbsp; 4</font><font size="2" face="Arial">) High 
	Potential:</font>

	<select name="High_Potential" size="1" style="width: 111; height: 21" >
				<option selected>Choose One...</option>
				<option value="Yes0" >Yes</option>
				<option value="No0" >No</option>
			</select ><font color="#FF0000"><%=response.write(rs("High_Potential"))%></font>
	</font>
	</fieldset></p>
As you can see above i have used response.write to show the user what value is in the DB.. but how do i get the value to automatically show up in the drop down list?
Reply With Quote
  #2  
Old March 30th, 2009, 09:35 AM
Rebelle's Avatar
Barn Loyal
 
Join Date: Mar 2008
Posts: 748
Rep Power: 2
Rebelle will become famous soon enough
Default

Hi wbva,

you need a select query....also, it appears your response.write is on the outside of the </select> tag. ?

How about something like this...

Code:
<select name="High_Potential" size="1" style="width: 111; height: 21" >
<%
Set Rs=Server.CreateObject("adodb.recordset")
strSQL = "SELECT DISTINCT HighPotential FROM yourTableName"
strSQL = strSQL & " ORDER BY HighPotential"
Rs.Open strSQL, conn

Do while not Rs.EOF
   if Request.Form("High_Potential") = Rs("High_Potential") then
      Response.Write "<OPTION VALUE = '" & Rs("High_Potential") & "' SELECTED>"
      Response.Write Rs("High_Potential") & "</Option>"
      Rs.MoveNext
   else
      Response.Write "<OPTION VALUE = '" & Rs("High_Potential") & "'>"
      Response.Write Rs("High_Potential") & "</Option>"
      Rs.MoveNext
   end if
loop

%>
</SELECT>
Reply With Quote
  #3  
Old March 30th, 2009, 09:50 AM
Centurion's Avatar
Barn Enthusiast
 
Join Date: Dec 2008
Posts: 352
Rep Power: 2
Centurion is on a distinguished road
Default

Quote:
Originally Posted by Rebelle View Post
Hi wbva,

you need a select query....also, it appears your response.write is on the outside of the </select> tag. ?

How about something like this...

Code:
<select name="High_Potential" size="1" style="width: 111; height: 21" >
<%
Set Rs=Server.CreateObject("adodb.recordset")
strSQL = "SELECT DISTINCT HighPotential FROM yourTableName"
strSQL = strSQL & " ORDER BY HighPotential"
Rs.Open strSQL, conn

Do while not Rs.EOF
   if Request.Form("High_Potential") = Rs("High_Potential") then
      Response.Write "<OPTION VALUE = '" & Rs("High_Potential") & "' SELECTED>"
      Response.Write Rs("High_Potential") & "</Option>"
      Rs.MoveNext
   else
      Response.Write "<OPTION VALUE = '" & Rs("High_Potential") & "'>"
      Response.Write Rs("High_Potential") & "</Option>"
      Rs.MoveNext
   end if
loop

%>
</SELECT>
hi, thanks for that.. but i have another query running at the top of the page... so i assume i change Rs to rs1 and it did seem to work.. but basically the page is so the user can update. and it only has Choose One in the box.. as its querying on those values. how would i add other selectable values ?

Code:
<%
'Checking to see what request is being submitted
	IF  Request.Form("submit")="submit" Then
	
	username=request.form("username")    ' Get the unique Ref being searched for
	
	'create a record set
		Set rs=Server.CreateObject("ADODB.RecordSet")
	'Query the database
		sql= "SELECT * FROM [Exec-3] WHERE username = '" & username& "'"
		rs.open sql, conn, 1, 1
		IF NOT rs.eof THEN
		
		response.write sql
		

		

%>
Reply With Quote
  #4  
Old March 30th, 2009, 10:00 AM
Rebelle's Avatar
Barn Loyal
 
Join Date: Mar 2008
Posts: 748
Rep Power: 2
Rebelle will become famous soon enough
Default

Hi wbva,

Not sure what you mean "other selectable values"...? .. other value other than from database?

Also, if you already had query at the top of page then you don't have to repeat...just start with the do while line.
Reply With Quote
  #5  
Old March 30th, 2009, 10:04 AM
Centurion's Avatar
Barn Enthusiast
 
Join Date: Dec 2008
Posts: 352
Rep Power: 2
Centurion is on a distinguished road
Default

Quote:
Originally Posted by Rebelle View Post
Hi wbva,

Not sure what you mean "other selectable values"...? .. other value other than from database?

Also, if you already had query at the top of page then you don't have to repeat...just start with the do while line.
I want to retreive the selected value from the database.. but also i want the option of having static values from the drop down list..

say the drop down retreives 'Yes' but the user wants to change this to 'No'.. they cant seem to do that as all the code does is retreieve.
Reply With Quote
  #6  
Old March 30th, 2009, 10:19 AM
Rebelle's Avatar
Barn Loyal
 
Join Date: Mar 2008
Posts: 748
Rep Power: 2
Rebelle will become famous soon enough
Default

ok, thought that but wanted to clarify .. .how about line in blue...i may have quotes wrong but give it a try.

Do while not Rs.EOF
if Request.Form("High_Potential") = Rs("High_Potential") then
Response.Write "<OPTION VALUE = 'No' SELECTED>"No</Option>"
Response.Write "<OPTION VALUE = '" & Rs("High_Potential") & "' SELECTED>"
Response.Write Rs("High_Potential") & "</Option>"
Rs.MoveNext
else
Response.Write "<OPTION VALUE = 'No' SELECTED>"No</Option>"
Response.Write "<OPTION VALUE = '" & Rs("High_Potential") & "'>"
Response.Write Rs("High_Potential") & "</Option>"
Rs.MoveNext
end if
loop
Reply With Quote
  #7  
Old March 30th, 2009, 10:22 AM
BLaaaaaaaaaarche's Avatar
Barn Frequenter
 
Join Date: Mar 2008
Posts: 157
Rep Power: 3
BLaaaaaaaaaarche will become famous soon enoughBLaaaaaaaaaarche will become famous soon enough
Default

Rebelle, you can achieve the same thing with much less code, using this logic:

Code:
Do While Not rs.EOF
	strHP = rs("High_Potential")
	response.write "<option value=""" & strHP & """"
	If CStr(Request.Form("High_Potential")) = CStr(strHP) Then
		response.write " selected"
	End If
	response.write ">" & strHP & "</option>" & vbCrLf
rs.MoveNext
Loop
Just thought I would share that with you.

WBVA, I have no clue what you are trying to say. Can you please rephrase your question?

Comments on this post
Rebelle agrees: Thanked Post
jmurrayhead agrees: Indeed
__________________
"You'll never be as perfect as BLaaaaaaaaarche."
Reply With Quote
The Following User Says Thank You to BLaaaaaaaaaarche For This Useful Post:
Rebelle (March 30th, 2009)
  #8  
Old March 31st, 2009, 05:08 AM
Centurion's Avatar
Barn Enthusiast
 
Join Date: Dec 2008
Posts: 352
Rep Power: 2
Centurion is on a distinguished road
Default

Quote:
Originally Posted by BLaaaaaaaaaarche View Post
Rebelle, you can achieve the same thing with much less code, using this logic:

Code:
Do While Not rs.EOF
	strHP = rs("High_Potential")
	response.write "<option value=""" & strHP & """"
	If CStr(Request.Form("High_Potential")) = CStr(strHP) Then
		response.write " selected"
	End If
	response.write ">" & strHP & "</option>" & vbCrLf
rs.MoveNext
Loop
Just thought I would share that with you.

WBVA, I have no clue what you are trying to say. Can you please rephrase your question?
Thanks for the code.. basically what i want to do is:

have a drop down box with the values Yes, No and N/A.

If the user (from another page) has inserted Yes, then my update page should retreive Yes into the drop down box.

As this is an update page it should have a choice of the other values in case the user wants to change the value to No.
Reply With Quote
  #9  
Old March 31st, 2009, 05:15 AM
Centurion's Avatar
Barn Enthusiast
 
Join Date: Dec 2008
Posts: 352
Rep Power: 2
Centurion is on a distinguished road
Default

got this error :

Error Type:
ADODB.Field (0x80020009)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
admin/Form3_Update.asp, line 93
Reply With Quote
  #10  
Old March 31st, 2009, 07:33 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,964
Blog Entries: 8
Rep Power: 15
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

Put BLarche's code between this:
Code:
If Not rs.BOF And Not rs.EOF Then
    ' BLarche's code here
End If
__________________
jmurrayhead
If you agree with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

If you like it here...throw us a few bones to help
support us.

Join our Folding team: DeveloperBarn Folding

Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > ASP Development

Bookmarks

Thread Tools
Display Modes

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 On


Similar Threads

Thread Thread Starter Forum Replies Last Post
best way to bind values to sql statement? Centurion ASP Development 11 March 17th, 2009 06:45 AM
getting values from tables todd2006 ASP Development 7 February 2nd, 2009 06:33 PM
Converting Null Values to Zero nboscaino Microsoft Access 3 September 4th, 2008 01:02 PM
finding values todd2006 ASP Development 2 June 23rd, 2008 02:03 AM
retrieve values todd2006 SQL Development 5 June 19th, 2008 01:46 PM


All times are GMT -4. The time now is 10:40 AM.


Copyright ©2008-2010, DeveloperBarn

Content Relevant URLs by vBSEO 3.3.2