Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用ASP.net或经典ASP.net将一个表的SQL数据插入html表_Asp.net_Sql_Sql Server_Sql Server 2008_Asp Classic - Fatal编程技术网

使用ASP.net或经典ASP.net将一个表的SQL数据插入html表

使用ASP.net或经典ASP.net将一个表的SQL数据插入html表,asp.net,sql,sql-server,sql-server-2008,asp-classic,Asp.net,Sql,Sql Server,Sql Server 2008,Asp Classic,关于一些背景信息,我是一名网络管理员/系统管理员,自学编程“技能”非常少。在过去,我只是修改和调整了现有的代码,以得到任何我想要的工作,但我没有任何运气与目前的项目。我希望将sql表中的动态价格添加到现有的html表中,仅用于sql表中的少数记录 我使用的是一个本地托管服务器,它使用IIS6,混合使用ASP.net 2.0和经典ASP,并在站点上使用2008 MS SQL server数据库 我已经连接到global.asa中的db,正在寻找如何将每个价格对应到表中的每个html项目编号 (我从

关于一些背景信息,我是一名网络管理员/系统管理员,自学编程“技能”非常少。在过去,我只是修改和调整了现有的代码,以得到任何我想要的工作,但我没有任何运气与目前的项目。我希望将sql表中的动态价格添加到现有的html表中,仅用于sql表中的少数记录

我使用的是一个本地托管服务器,它使用IIS6,混合使用ASP.net 2.0和经典ASP,并在站点上使用2008 MS SQL server数据库

我已经连接到global.asa中的db,正在寻找如何将每个价格对应到表中的每个html项目编号

(我从不同的asp文件中复制/粘贴的sql代码具有不同的意图,因此,如果某些内容看起来完全不符合其要求,可能是因为:[)

例:


项目编号
描述
价格
零件号1
说明1
零件号2
说明2
零件号3
说明3
谢谢


斯坦

太近了!您需要在表行周围进行循环。用以下内容替换您的表:

if NOT rs.eof then rs.MoveFirst

'...remove this code from your exampl (above), snip---'
   DerivedPrice = rs("DerivedPrice")

rs.close 'especially this code'
Set rs = Nothing  'and this code'
'---snip, end----'
%>
<%= rs.RecordCount %> Rows<br/> <!-- optional, for troubleshooting -->

<table>
  <tr>
    <th>Item Number</th>
    <th>Description</th>
    <th>Price</th>
  </tr>
<%
While NOT rs.eof  'loop through the dataset'
%>
  <tr>
    <td><%= rs("PartNumber") %></td>
    <td><%= rs("Description") %></td>
    <td><%= rs("DerivedPrice") %></td>
  </tr>
<%
   rs.MoveNext
Wend 'end while

rs.close
Set rs = Nothing
%> 
</table>
如果不是rs.eof,那么rs.MoveFirst
“…从示例(上面)中删除此代码,然后剪掉--”
DerivedPrice=rs(“DerivedPrice”)
rs.close“尤其是此代码”
设置rs=Nothing'和此代码'
“剪断,结束”
%>
行数
项目编号 描述 价格
html表格中的项目编号是如何填充的?(在html页面中硬编码或在不同的select中动态呈现?)如果选择不同的select,您可能可以同时获得价格和商品信息,这将是最有效的。否则,您需要修改select语句,以按唯一的商品编号(可能是按商品编号)收回html表中的一个或所有商品。非常感谢您的帮助!看起来我在其他地方也弄糟了,是吗s只抓取第一条记录,但在服务器上的查询中使用的同一sql语句拉取了1428行,是不是与我的cursortyp,locktyp值有关?ThanksCursortyp,locktyp,您正在使用的应该是一个双向读/写数据集。没有比这更强大的了。我添加了几行代码用于故障排除。它输出e rowcount(应显示1428)给了我..Microsoft VBScript运行时错误“800a01b6”对象不支持此属性或方法:“rowcount”噢,对不起。rowcount是SQL。我指的是RecordCount。
if NOT rs.eof then rs.MoveFirst

'...remove this code from your exampl (above), snip---'
   DerivedPrice = rs("DerivedPrice")

rs.close 'especially this code'
Set rs = Nothing  'and this code'
'---snip, end----'
%>
<%= rs.RecordCount %> Rows<br/> <!-- optional, for troubleshooting -->

<table>
  <tr>
    <th>Item Number</th>
    <th>Description</th>
    <th>Price</th>
  </tr>
<%
While NOT rs.eof  'loop through the dataset'
%>
  <tr>
    <td><%= rs("PartNumber") %></td>
    <td><%= rs("Description") %></td>
    <td><%= rs("DerivedPrice") %></td>
  </tr>
<%
   rs.MoveNext
Wend 'end while

rs.close
Set rs = Nothing
%> 
</table>