简体   繁体   English

如何用SQL Server中的数据填充Select? 使用ASP经典

[英]How to fill a Select with data from SQL Server? Using ASP Classic

I'm a newbie programming on ASP Classic and I'm trying to fill a Select with information from SQL Server tables, but I got trouble trying to separate two columns, I need put a column on Value side and the other one outside option just for display the name of the option. 我是ASP Classic上的新手编程,我试图用SQL Server表中的信息填充Select,但是尝试分隔两列时遇到了麻烦,我需要在Value侧放置一列,而在外部放置一个选项用于显示选项的名称。

I'm trying to get this: 我试图得到这个:

<option value="Field_1">Field_2</option>

I'm trying with different loop ways, but I still am getting 2 columns combined inside my value. 我正在尝试使用不同的循环方式,但是我的值中仍然合并了2列。

Like this: 像这样:

<option value="Field_1Field_2"> </option>

This is my code - I appreciate any ideas. 这是我的代码-感谢您提出任何建议。

Thanks 谢谢

set rs = Server.CreateObject("ADODB.Recordset")
SQL = "SELECT id_geren, Acron FROM tbl_geren"
rs.open SQL, conect
<html>
<body>
<select id="" style="width:65px"> 

<% do until rs.EOF %>
<option value=
<% for each x in rs.fields %>
<% Response.Write(x) %>
<% next
rs.MoveNext %>
></option>
<%  loop
rs.close

%>
</select>
</body>
</html>

I expect the output like this: 我期望这样的输出:

<option value="id_geren">Acron</option>

but the actual output is: 但实际输出是:

<option value="id_gerenAcron"></option>

You don't need to iterate over the individual fields as they can be accessed independently; 您无需遍历各个字段,因为它们可以独立访问。

<% do until rs.EOF %>
<option value=“<%= rs(“id_geren”) %>”><%= rs(“Acron”) %>”></option>
<% rs.MoveNext %>
<% loop
rs.close
%>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用服务器端Javascript访问Classic Asp上的表单数据 - Accessing Form Data on Classic Asp using server side Javascript 使用jQuery从HTML Select调用数据属性,该属性包括SQL查询以动态填充Classic ASP中的其他HTML输入 - Calling data-attribute from HTML Select with jQuery that includes SQL query to dynamically populates other HTML input in Classic ASP 通过经典asp和vbscript更新sql服务器 - Updating sql server through classic asp and vbscript 如何从经典ASP中的HTML表发布数据 - How to Post Data from HTML Table in Classic ASP 将varchar值&#39;%%&#39;转换为数据类型int时,经典SQL形式的SQL Server转换失败 - Classic ASP form giving SQL Server Conversion failed when converting the varchar value '%%' to data type int 按钮单击 asp 以删除 SQL 服务器中的行 - 经典 asp 和 vbscript - Button Click for asp to Delete Row in SQL server - classic asp and vbscript 如何使用之前 SELECT SQL 数据的结果 SELECT - How to SELECT SQL data using the results from a previous SELECT 如何使用python从经典的asp网站Webscrape数据。 提交POST表单后,我无法获得结果 - How to Webscrape data from a classic asp website using python. I am having trouble getting the result after submitting the POST form 如何迁移数据以更新ASP经典版 - how to migrate data to update form ASP classic 经典ASP-选择下拉列表中的IF语句 - Classic ASP - IF statement in a select drodown
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM