473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

ASP - Calling a result set and populate as selection from DB

Hi, I am trying to call a recordset from sql server and populate them into a html drop sown selection box.

Expand|Select|Wrap|Line Numbers
  1.  Set conn = CreateObject("ADODB.Connection") 
  2. conn.Open "Driver={SQL Server};Server=cslproxy;Database=gra;Trusted_Connection=yes;"
  3. sql = "select * from rerturn_reasons"
  4. rs2.open sql, conn
  5. If Not rs2.eof Then
  6.     response.write vbcrlf & "<tr><td>Reason for Return:</td><td><select name=selectreason>"
  7.  
  8. Do While Not rs2.eof
  9.     response.write vbcrlf & "<option"
  10. If rs2(0) = rs2("option_text") Then
  11.     response.write vbcrlf & "selected=selected"
  12.     End If
  13. response.write ">" & rs2("option_text") & "</option>"
  14.     rs2.movenext
  15. Loop
  16. response.write vbcrlf & "</select></td></tr>"
  17. End if
  18. rs2.close
  19. conn.close
  20.  

but i got error on it. Could any body check my code?
Jul 17 '08 #1
6 2296
idsanjeev
241 100+
can you provide more detials about error
Jul 17 '08 #2
DrBunchman
979 Expert 512MB
As idsanjeev says we'll need the error to be sure of what the problem is. Glancing at your code though you don't seem to create your recordset object anywhere e.g.
Expand|Select|Wrap|Line Numbers
  1. Set rs2 = CreateObject("ADODB.RecordSet")
Dr B
Jul 17 '08 #3
jeffstl
432 Expert 256MB
Without knowing which line you are getting the error, I am seeing 2 problems that would cause errors for certain.

One you need to specifiy the server object to create a connection. Like this

Expand|Select|Wrap|Line Numbers
  1. Set conn = Server.CreateObject("ADODB.Connection") 
  2.  
Second thing is in ASP code, Do While loops are ended with the syntax wend (short for While Loop End I would imagine) So you need this

Expand|Select|Wrap|Line Numbers
  1. Do While
  2.  
  3. Wend
  4.  
Jul 18 '08 #4
jhardman
3,406 Expert 2GB
... in ASP code, Do While loops are ended with the syntax wend (short for While Loop End I would imagine) So you need this

Expand|Select|Wrap|Line Numbers
  1. Do While
  2.  
  3. Wend
  4.  
no, "do while ... loop" is correct. There is an alternate syntax "while...wend" which does not use the "do". these two structures are completely redundant, both work perfectly.

Jared
Jul 18 '08 #5
jeffstl
432 Expert 256MB
no, "do while ... loop" is correct. There is an alternate syntax "while...wend" which does not use the "do". these two structures are completely redundant, both work perfectly.

Jared
woops

Scattered brain, correct...sorry
Jul 21 '08 #6
Thanks every one, I got it fixed.
Aug 6 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: godber | last post by:
I need to populate text boxes for instance with employee information using their unique employee works number selected from a combo box. Can anyone help, I am told thru visual basic this can be...
2
by: Mark | last post by:
Any suggestions on how to go about generating a popup, giving the user a way of searching for something, and then taking their selection after closing the pop-up and populating the parent form with...
14
by: Barney | last post by:
How can I populate a textbox from a dataview? I have a dataset i'm filtering on and i want to populate several textboxes based on that filter. How can i get that to work? I've tried: ...
0
by: ROO | last post by:
Hi Everyone, I have a database table that have 4 field( C1, C2, M1, M2) on my form i have two combo box ComboC and ComboM C1 C2 M1 M2 1 ...
13
by: monomaniac21 | last post by:
hi i want to be able to trigger a javascript style popup alert in php (i want a message displayed on the actual page) is this possible?
0
by: Steve1974 | last post by:
Hi All I am currently using Access to output to excel. The creation of the worksheet goes ok, and then I have a piece of code (recorded from an Excel macro) to create pick lists for two columns...
4
by: whamo | last post by:
I have the need to populate a field based on the selection in a combo box. Starting out simple. (2) tables tbl_OSE_Info and tbl_Input; tbl_OSE_Info has three fields: Key, OSE_Name and OSE_Wt...
2
by: Ronald | last post by:
I hope somebody can help. I can't get into the specifics of my project, but I'll try to create a simple example: tblVehicle * VIN (text box) * Make (text box) * Model (text box) frmRepair
1
by: KMEscherich | last post by:
Platform = Windows Program = Access 2003 Hi there, I am stumpped!! I am attempting to populate a form control as follows: I have a form that has 2 drop-down boxes. One retrieves the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.