ASP - SQL问题 [英] ASP - SQL problem

查看:49
本文介绍了ASP - SQL问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮忙!


我的表格有问题!我需要能够在页面加载时从一个表中提取
来获取信息和

在我做出更改后更新另一个表但是

第二次页面加载我想从第二个表加载信息

而不是从原始位置加载。

如何做这样的事情?

请参阅下面的代码!我添加了大量评论!


感谢您的帮助!

..:代码:。


< html>

< head>

< title> Untitled Document< / title>

< meta http-equiv = QUOT;内容类型" content =" text / html;

charset = iso-8859-1">

<%''将更新的信息提交到asp更新页面%> ;

< script>

function changetax(){

document.forma.task.value =" CT" ;;

document.forma.submit();

< / script>


<%

dim rs,tmprs,conn,sql

dim procid,tableid,symbol

dim task,menu,exrate,currname


set conn = server.createobject(" adodb.connection")

conn.open(application(" proc"))


procid = request(" ; procid")

task = request(" task")

sql =" select * from tblpurchase where procid =''" &

procid& "'';"

set rs = conn.execute(sql)

sql =" select * from tblCurrency,其中CurrencyID =" &安培; rs

(" CurrencyID")& ""

set tmprs = conn.execute(sql)

symbol = tmprs(" CurrencySymbol")

exrate = tmprs (ExRate)

TaxAmount = tmprs(TaxAmt)

%>

< / head>


< body>

< form name =" forma"行动= QUOT; dosupplies.asp" method =" post">


< font style =" font-size:12pt;">< b>新商品< / b>< / font>

< table cellpadding = 3 cellspacing = 0 border = 0>


< tr>< td valign =" top"> < b>描述< / b>< / td>

< td colspan = 3>< textarea name =" description0" cols =" 50"

rows =" 2">< / textarea>< / td>


< / tr>


< tr>

< td valign =" bottom">< b>数量< / b>< / td>

< td valign =" bottom">< b>单位类型< / b>< / td>

< td valign =" bottom"> ;< b>费用< / b>< / td>

< td valign =" bottom" align =" center">< b>(%)

< br>折扣< / b>< / td>

< / tr>


< tr>< td>< input name =" quan0"值= QUOT 1 QUOT; size = 4>< / td>

< td>< select name =" unit0">

<%虽然不是alphars.eof%> ;

< option value ="<%= alphars(" unit")%>"><%= alphars

("" unit")%>& nbsp;(<%= alphars(" unitdesc")%>)

<%alphars.movenext

wend

alphars.movefirst

%>< / select>< / td>

< td>< input name =" unitcost0"值= QUOT; 0" size = 10>< / td>

< td>< input name =" disc0"值= QUOT; 0" size = 5>< / td>

< td colspan = 1>

< input type =" button" value =" add this item"

onclick =" javscript:newitem();">

<%if step> 0然后%>

< input type =" button" value ="下一个(没有更多项目)

Hi Can someone please help!

I am having a problem with a form! I need to be able to
pull information from one table when the page loads and
update another table after I have made changes but the
second time the page loads I want to load the information
from the second table and not from the origional location.
How do I do something like this?
See the code below! I have added a whole load of comments!

Thanks for any help!
..: CODE :.

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<%''Submits the updated info to an asp update page%>
<script>
function changetax () {
document.forma.task.value = "CT";
document.forma.submit ();
</script>

<%
dim rs, tmprs, conn, sql
dim procid, tableid, symbol
dim task, menu, exrate, currname

set conn = server.createobject("adodb.connection")
conn.open (application("proc"))

procid = request("procid")
task = request("task")

sql = "select * from tblpurchase where procid = ''" &
procid & "'';"
set rs = conn.execute(sql)

sql = "select * from tblCurrency where CurrencyID = " & rs
("CurrencyID") & ";"
set tmprs = conn.execute(sql)
symbol = tmprs("CurrencySymbol")
exrate = tmprs("ExRate")
TaxAmount = tmprs("TaxAmt")
%>
</head>

<body>
<form name="forma" action="dosupplies.asp" method="post">

<font style="font-size:12pt;"><b>New item</b></font>
<table cellpadding=3 cellspacing=0 border=0>

<tr><td valign="top"><b>Description</b></td>
<td colspan=3><textarea name="description0" cols="50"
rows="2"></textarea></td>

</tr>

<tr>
<td valign="bottom"><b>Qty</b></td>
<td valign="bottom"><b>Unit type</b></td>
<td valign="bottom"><b>Cost</b></td>
<td valign="bottom" align="center"><b>(%)
<br>Discount</b></td>
</tr>

<tr><td><input name="quan0" value="1" size=4></td>
<td><select name="unit0">
<% while not alphars.eof %>
<option value="<%=alphars("unit")%>"><%=alphars
("unit")%>&nbsp;(<%=alphars("unitdesc")%>)
<% alphars.movenext
wend
alphars.movefirst
%></select></td>
<td><input name="unitcost0" value="0" size=10></td>
<td><input name="disc0" value="0" size=5></td>
<td colspan=1>
<input type="button" value="add this item"
onclick="javscript:newitem();">
<% if step > 0 then %>
<input type="button" value="Next (no more items)

" onclick =" javascript :doit();">< br>
" onclick="javascript:doit();"><br>


<%end if if>

< ; / td>

< / tr>


< / table>


<! - - 当前添加的项目--->


< hr>

< font style =" font-size:12pt;"> ;< b>当前行

项< / b>< / font>

<%如果不是tmprs.eof则%>

< table cellpadding = 3 cellspacing = 0 border = 0>


<%count = 0


而不是tmprs。 eof

count = count + 1

subtotal = tmprs(" Quantity")* tmprs(" UnitCost")%>


< tr>< td valign =" bottom">< b>#< / b>< / td>

< td valign =" bottom" ;>< b>数量< / b>< / td>

< td valign =" bottom">< b>单位类型< / b>< / td> ;

< td valign =" bottom">< b> Cost< ; / b>< / td>

< td valign =" bottom" align =" center">< b>(%)

< br>折扣< / b>< / td>

< td valign = " bottom"

align =" center">< b>总计< BR>折扣< / b>< / td>

< td valign = QUOT;底部" align =" center">< b> Tax< / b>< / td>

< td valign =" bottom" align =" center">< b> Total< / b>< / td>

< / tr>


< tr> ;< td><%= tmprs(" itemno")%>< / td>

< td>< input name =" quan<%= count%> ;" value ="<%= tmprs

(" Quantity")%>" size = 4>< / td>

< td>< select name =" unit<%= count%>">

< %而不是alphars.eof%>

< option value ="<%= alphars(" unit")%>" <%if

alphars(" unit")= tmprs(" unit")then response.write

(" SELECTED")%>> <%= alphars(" unit")%>& nbsp;(<%= alpha rs

(" unitdesc")%>)

<%alphars.movenext

wend

alphars.movefirst


''将所有单位成本加在一起以提供小计


Pdiscount = tmprs(" Disc")

Tdiscount = formatnumber((subtotal)/ 100 * Pdiscount)

Ttax =((小计-Tdiscount)/ 100)* TaxAmount

totalcost =(小计-Tdiscount)+ Ttax

%>

< / select>

< / td>

< td>< input name =" unitcost<%= count%>" value ="<%= tmprs

(" UnitCost")%>" size = 10>< / td>

< td>< input name =" disc<%= count%>" value ="<%

= Pdiscount%>" size = 5>< / td>

< td align =" center"><%= Tdiscount%>< / td>

< ; td align =" center"><%= Ttax%>< / td>

< td align =" right">< b><%= formatnumber(TOTALCOST)%LT; / b>< / TD>
< td>

& nbsp;< input type =" button" value =" update"

onclick =" javscript:updateitem(<%= count%>,<%= tmprs

(" supplyid") %>);">

< input type =" button" value =" delete"

onclick =" javscript:killitem(<%= count%>,<%= tmprs

(" supplyid") %>,<%= tmprs(" itemno")%>);">

< / td>

< / tr>


< tr>< td colspan = 2 valign =" top">< b>说明< / b>< / td>

< td colspan = 4>< textarea name =" description<%= count%>"

cols =" 50" rows =" 2"><%= tmprs(" Description")%< / textarea>< / td>

<% end if %>
</td>
</tr>

</table>

<!--- Current Added items --->

<hr>
<font style="font-size:12pt;"><b>Current line
items</b></font>
<% if not tmprs.eof then %>
<table cellpadding=3 cellspacing=0 border=0>

<% count = 0

while not tmprs.eof
count = count + 1
subtotal = tmprs("Quantity") * tmprs("UnitCost") %>

<tr><td valign="bottom"><b>#</b></td>
<td valign="bottom"><b>Qty</b></td>
<td valign="bottom"><b>Unit type</b></td>
<td valign="bottom"><b>Cost</b></td>
<td valign="bottom" align="center"><b>(%)
<br>Discount</b></td>
<td valign="bottom"
align="center"><b>Total<BR>Discount</b></td>
<td valign="bottom" align="center"><b>Tax</b></td>
<td valign="bottom" align="center"><b>Total</b></td>
</tr>

<tr><td><%=tmprs("itemno")%></td>
<td><input name="quan<%=count%>" value="<%=tmprs
("Quantity")%>" size=4></td>
<td><select name="unit<%=count%>">
<% while not alphars.eof %>
<option value="<%=alphars("unit")%>" <%if
alphars("unit")=tmprs("unit") then response.write
("SELECTED")%>><%=alphars("unit")%>&nbsp;(<%=alpha rs
("unitdesc")%>)
<% alphars.movenext
wend
alphars.movefirst

''Adds all unit costs together to provide a subtotal

Pdiscount=tmprs("Disc")
Tdiscount=formatnumber((subtotal) / 100 * Pdiscount)
Ttax=((subtotal-Tdiscount)/100) * TaxAmount
totalcost=(subtotal-Tdiscount)+Ttax
%>
</select>
</td>
<td><input name="unitcost<%=count%>" value="<%=tmprs
("UnitCost")%>" size=10></td>
<td><input name="disc<%=count%>" value="<%
=Pdiscount%>" size=5></td>
<td align="center"><%=Tdiscount%></td>
<td align="center"><%=Ttax%></td>
<td align="right"><b><%=formatnumber(totalcost)%</b></td> <td>
&nbsp;<input type="button" value="update"
onclick="javscript:updateitem(<%=count%>,<%=tmprs
("supplyid")%>);">
<input type="button" value="delete"
onclick="javscript:killitem(<%=count%>,<%=tmprs
("supplyid")%>,<%=tmprs("itemno")%>);">
</td>
</tr>

<tr><td colspan=2 valign="top"><b>Description</b></td>
<td colspan=4><textarea name="description<%=count%>"
cols="50" rows="2"><%=tmprs("Description")%</textarea></td>



< / tr>


<%tmprs.movenext

wend

%>

< / table>

<%else%>

< br>目前没有订单项。

<%end if%>


<%

''见下文

''税收百分比允许用户更改

从一个替代品而不是

'的税率,从表tblcurrencies中取出的默认值,但当

''这样做时,它不应该改变价值在

''tblcurrencies表中,而不是在tblpuchase。

''这就是为什么第二次加载页面时它不会没有

''更长时间使用tblcurrencies表来获取它的信息

''而不是tblpurchase表。

%>


< hr>

< font style =& ; font-size:12pt;">< b>此额外费用

采购< / b>< / font>

< table cellpadding = 3 cellspacing = 0 border = 0>

< tr>< td

valign =" top">< b> Tax& nbsp;百分比: < / b>& nbsp;< / td>< td

valign =" top">

< input name =" taxamt"值= QUOT;<%= TAXAMOUNT%GT;" size = 3>%

< / td>< / tr>

< tr>< td

valign =" top">< b>送货& nbsp;费用:< / b>& nbsp;< / td>< td

valign =" top">

< input name =" ShipCost" value ="<%= rs(" ShipCost")%>"

size = 12>< / td>< / tr>

< tr>< td valign =" top">< b>附加费:< / b>< / td>& nbsp;< td

valign =" top">

< input name =" SurCharge" value ="<%= rs(" SurCharge")%>"

size = 12>< / td>< / tr>

< / tr>

< tr>< td>< / td>< td>< input type =" button" value ="更新费用

更改 onclick =" javascript :changetax();">

< / td>< / tr>


< / table>

<%set tmprs = nothing%>

<%set alphars = nothing%>

< / body>

< / html>


</tr>

<% tmprs.movenext
wend
%>
</table>
<% else %>
<br>Currently there no line items.
<% end if %>

<%
''See below
''Tax Percentage allows the user to change the
''tax percentage to an alternative rather than the
''default taken from the table tblcurrencies, however when
''this is done it shouldn''t change the value in the
''tblcurrencies table but rather in the tblpuchase.
''This is why the second time the page loads it sould no
''longer use the tblcurrencies table for it''s information
''but rather the tblpurchase table.
%>

<hr>
<font style="font-size:12pt;"><b>Extra costs for this
procurement</b></font>
<table cellpadding=3 cellspacing=0 border=0>
<tr><td
valign="top"><b>Tax&nbsp;Percentage:</b>&nbsp;</td><td
valign="top">
<input name="taxamt" value="<%=TaxAmount%>" size=3>%
</td></tr>
<tr><td
valign="top"><b>Shipping&nbsp;Cost:</b>&nbsp;</td><td
valign="top">
<input name="ShipCost" value="<%=rs("ShipCost")%>"
size=12></td></tr>
<tr><td valign="top"><b>Surcharges:</b></td>&nbsp;<td
valign="top">
<input name="SurCharge" value="<%=rs("SurCharge")%>"
size=12></td></tr>
</tr>
<tr><td></td><td><input type="button" value="update costs
changes" onclick="javascript:changetax();">
</td></tr>

</table>
<% set tmprs = nothing %>
<% set alphars = nothing %>
</body>
</html>

推荐答案

随着你所有不必要的HTML发布,你的帖子太长了

阅读。根据你在html上面写的内容,看起来你正在寻找

这样的东西。 http://www.aspfaq.com/show.asp?id= 2270 如果没有,

回复时只提供必要的html或代码,而你的代码是不行的。


Ray at work


" MyaTiX" <一个******* @ discussions.microsoft.com>在留言中写道

news:10 ***************************** @ phx.gbl ...
With all that unecessary html that you posted, your post is too long to
read. From what you wrote above the html, it appears that you''re looking
for something like this. http://www.aspfaq.com/show.asp?id=2270 If not,
post back with only necessary html or code that you have that isn''t working.

Ray at work

"MyaTiX" <an*******@discussions.microsoft.com> wrote in message
news:10*****************************@phx.gbl...
您好,有人可以帮忙!

我的表格有问题!我需要能够在页面加载时从一个表中提取信息并在我进行更改后更新另一个表但是第二次加载页面时我想加载信息<从第二个表开始,而不是从原始位置开始。

如何做这样的事情?
Hi Can someone please help!

I am having a problem with a form! I need to be able to
pull information from one table when the page loads and
update another table after I have made changes but the
second time the page loads I want to load the information
from the second table and not from the origional location.
How do I do something like this?



MyaTiX写道:
您好,有人可以帮忙!

我的表格有问题!我需要能够在页面加载时从一个表中提取信息并在我进行更改后更新另一个表但是第二次加载页面时我想加载信息<来自第二个表而不是来自原始位置。
Hi Can someone please help!

I am having a problem with a form! I need to be able to
pull information from one table when the page loads and
update another table after I have made changes but the
second time the page loads I want to load the information
from the second table and not from the origional location.




这听起来很奇怪^ H ^ H ^ H ^ H非常复杂。为什么不简单地在表格中包含一个列,以指定数据是否已被编辑?为什么将

相同的数据存储在两个表中?很抱歉,如果你在你发布的

大量的代码中回答了这些问题,但我没有时间来完成这个

的事情来找到答案。


鲍勃巴罗斯

-

微软MVP - ASP / ASP.NET

请回复新闻组。我的From

标题中列出的电子邮件帐户是我的垃圾邮件陷阱,因此我不经常检查它。通过发布到新闻组,您将获得更快的回复。



This sounds ridi^H^H^H^H very convoluted. Why not simply include a column in
your table to specify whether the data has been edited or not? Why store the
same data in two tables? I''m sorry if you answered these questions in the
mass of code you posted, but I simply do not have time to plow through this
thing to find the answers.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don''t check it very often. You will get a
quicker response by posting to the newsgroup.


请不要多重帖子MyaTiX。这绝对是一个与数据库相关的问题

所以.asp.db是发布它的完美组合。将它作为

发布,并没有增加你得到答案的机会(我们大多数人都是b $ b订阅这两个组)。相反,如果有人花了他的时间

在这里回答它,只是发现它已经在其他

组中解决了,那个人可能已经生气了足以忽略你未来的任何帖子

,从而减少你将来获得帮助的机会。


有时你不确定哪个小组是最合适的,

,你会想要向两个小组发一个问题。在这种情况下,你应该使用交叉发布技术,而不是多次发布相同的消息

。要进行交叉发布,请在帖子的收件人:标题中添加一个以分号分隔的

新闻组列表,并将其发布为

一次。它以及对它的任何回复都将出现在你的列表中的所有新闻组中。所以,如果我在.asp.db回复,我的回复也会出现在

..asp.general。


* ...或者其他什么分隔符被新闻客户认可


Bob Barrows

-

Microsoft MVP - ASP / ASP.NET

请回复新闻组。我的From

标题中列出的电子邮件帐户是我的垃圾邮件陷阱,因此我不经常检查它。通过发布到新闻组,您将获得更快的回复。
Please do not multipost MyaTiX. This is definitely a database-related
question
so .asp.db was the perfect group in which to post it. Posting it here as
well did not increase your chances of getting an answer (most of us
subscribe to both groups). On the contrary, if somebody had taken his time
to answer it here, only to find that it was already resolved in the other
group, that person may have been annoyed enough to ignore any future posts
from you, thereby decreasing your chances of getting help in the future.

There are times when you will not be sure which group is most appropriate,
and you will want to post a question to both groups. In that situation, you
should use the cross-posting technique, rather than posting the same message
multiple times. To crosspost, put a semicolon-delimited* list of the
newsgroups to which you wish to post in the To: header of your post and post
it once. It, and any replies to it, will appear in all the newsgroups in
your list. So, if I reply in .asp.db, my reply will also appear here in
..asp.general.

* ... or whatever delimiter is recognized by your news client

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don''t check it very often. You will get a
quicker response by posting to the newsgroup.


这篇关于ASP - SQL问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆