Solved

First Element of an ASP recordset not being displayed

Posted on 2003-11-10
3
391 Views
Last Modified: 2008-03-10
I am having problems with an ASP recordset
I am getting data back but it always returns minus the first row in the table

here is the code

btw I am using to populate a drop down box

Dim oConn
  Dim oRS, oRSD
  Dim adOpenKeyset
  Dim adLockOptimistic
  adOpenKeyset = 1
  adLockOptimistic = 3
 
  Set oConn=Server.CreateObject("ADODB.connection")
  Set oRS=Server.CreateObject("ADODB.Recordset")
  strSource = "Provider=SQLOLEDB;Data Source=(local)"
  strSource = strSource & ";User ID=;Password=;InitialCatalog=Project"
  oConn.ConnectionString = strSource
  oConn.Open

sqltext = "SELECT UserID FROM profile " 
  oRS.Open sqltext, oConn

Response.Write "<SELECT name=UserID> "
      Response.Write oRS.getString(,-1,"","<option>","</option>")
      Response.Write "</SELECT>"
0
Comment
Question by:michealo
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
af500 earned 500 total points
ID: 9716933
try this:

<select name="name">
<%
Set oRs=Server.CreateObject("adodb.recordset")
strSQL = "SELECT UserID FROM profile"
oRs.Open strSQL, conn

do while not ors.eof
      Response.Write "<OPTION VALUE = '" & oRS (0) & "' SELECTED>"
      Response.Write oRs(0) & "</Option>"
      oRs.MoveNext
loop

%>
</select>
0
 

Author Comment

by:michealo
ID: 9717356
Thanks af500 spot on
0
 
LVL 4

Expert Comment

by:af500
ID: 9717487
np ;)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now