If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > asp/ado

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-28-03, 04:48
zarifa_dewey zarifa_dewey is offline
Registered User
 
Join Date: Oct 2003
Posts: 7
asp/ado

hi i'm trying to create a drop down menu which calls the items listed from a database. for some reason i get a 'can't display window or can't find window' what am i doinf wrong. pls pls help!!!





<html>
<body>
<link href="ConnectDB.asp">
<%
dim connectionString
dim noRecsCode
dim connectDB

connectionString = "Driver={SQL Server}";
connectionString = connectionString & "Server=MISWARE";
connectionString = connectionString & "Database=COLDATA";
connectionString = connectionString & "uid=reports";
connectionString = connectionString & "pwd=reports";

set ConnectDB = server.createObject("ADODB.Connection")
connectDB.open connectionString

set rs=Server.CreateObject("ADODB.recordset")
sql="SELECT DISTINCT EOrigin FROM Ethnic_origin ORDER BY EId"
rs.Open sql,conn
EOrigin=request.form("EOrigin")

%>

<form method="post">
Choose Country <select name="EOrigin">
<% do until rs.EOF
response.write("<option")
if rs.fields("EOrigin")=EOrigin then
response.write(" selected")
end if
response.write(">")
response.write(rs.fields("EOrigin"))
rs.MoveNext
loop
rs.Close
set rs=Nothing %>
</select>
<input type="submit" value="Show customers">
</form>

<%
if country<>"" then
sql="SELECT EId,EOrigin FROM Ethnic_origin WHERE EOrigin='" & EOrigin & "'"
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn
%>
<table width="100%" cellspacing="0" cellpadding="2" border="1">
<tr>
<th>EId</th>
<th>EOrigin</th>
</tr>
<%
do until rs.EOF
response.write("<tr>")
response.write("<td>" & rs.fields("EId") & "</td>")
response.write("<td>" & rs.fields("EOrigin") & "</td>")
response.write("</tr>")
rs.MoveNext
loop
rs.close
conn.Close
set rs=Nothing
set conn=Nothing%>
</table>
<% end if %>

</body>
</html>
Reply With Quote
  #2 (permalink)  
Old 10-28-03, 08:30
vextout vextout is offline
Registered User
 
Join Date: Jan 2003
Location: New York
Posts: 160
Your Problem lies in your first slect statement

sql="SELECT DISTINCT EOrigin FROM Ethnic_origin ORDER BY EId"

You can not use "Order By" if that item is not selected
real error message:
ORDER BY items must appear in the select list if SELECT DISTINCT is specified.

so you have 2 possiblities

1 - eliminate order by
sql="SELECT DISTINCT EOrigin FROM Ethnic_origin"

2 - add Eid in selection
sql="SELECT DISTINCT EOrigin,Eid FROM Ethnic_origin ORDER BY EId"
__________________
Beyond Limitation
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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