弄不懂啊!!

liberty2000 2002-09-17 06:17:25
我的程序如下:想达到的目的是,当trans_order表中的“业务流水号”和update1表中的一样,那么就更新trans_order中的该条数据,否则就添加数据,可是弄了两天了还是不能实现,不知道除了什么错误,请指教!谢谢!!
<%
dim sql
dim rs
dim conn

dim sql1
dim rs1
dim conn1

dim sql2
dim rs2
dim conn2

set rs=server.createobject("adodb.recordset")
conn = "DBQ=" + server.mappath("trans_order.mdb") + ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
sql="select * from trans_order"
rs.Open sql,conn,1,3

set rs2=server.createobject("adodb.recordset")
conn2 = "DBQ=" + server.mappath("trans_order.mdb") + ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"

set rs1=server.createobject("adodb.recordset")
conn1 = "DBQ=" + server.mappath("update1.mdb") + ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
sql1="select * from update1"
rs1.Open sql1,conn1,1,3

dim yewuid
yewuid=0
while not rs1.EOF
temp1=rs1("业务流水号")
t1=rs1("部门简称")
t3=rs1("进口日期")
t4 =rs1("卸货地点")
t5 =rs1("客户自编号")
t6 =rs1("客户简称")
t7 =rs1("经营单位")
t8 =rs1("运输工具")
t9 =rs1("接单日期")
t10 =rs1("查验日期")
t11 =rs1("放行日期")
t12 =rs1("提单号")
t13 =rs1("件数")
t14 =rs1("毛重")
t15 =rs1("备注")
t16 =rs1("品名")
t17 =rs1("操作员")
t18 =rs1("报关单号")
t19 =rs1("整拼散")
t20 =rs1("通关单号")
t21 =rs1("联系人")
t22 =rs1("电话")
t23 =rs1("手机")
t24 =rs1("传真")
t25 =rs1("地址")
t26 =rs1("邮编")

while not rs.EOF
temp=rs("业务流水号")
if temp1=temp then
yewuid=temp
exit do
end if
rs.movenext
wend
rs.movefirst

response.write yewuid
if yewuid<>"0" then
sql2="update trans_order set 部门简称='"&t1&"',进口日期='"&t3&"',卸货地点='"&t4&"',客户自编号='"&t5&"',客户简称='"&t6&"',经营单位='"&t7&"',运输工具='"&t8&"',接单日期='"&t9&"',查验日期='"&t10&"',放行日期='"&t11&"',提单号='"&t12&"',件数='"&t13&"',毛重='"&t14&"',备注='"&t15&"',品名='"&t16&"',操作员='"&t17&"',报关单号='"&t18&"',整拼散='"&t19&"',通关单号='"&t20&"',联系人='"&t21&"',电话='"&t22&"',手机='"&t23&"',传真='"&t24&"',地址='"&t25&"',邮编='"&t26&"' where 业务流水号='"&yewuid&"'"
rs2.open sql2,conn2,1,1

else

rs.addnew

rs("部门简称") =rs1("部门简称")
rs("业务流水号") =rs1("业务流水号")
rs("进口日期") =rs1("进口日期")
rs("卸货地点") =rs1("卸货地点")
rs("客户自编号") =rs1("客户自编号")
rs("客户简称") =rs1("客户简称")
rs("经营单位") =rs1("经营单位")
rs("运输工具") =rs1("运输工具")
rs("接单日期") =rs1("接单日期")
rs("查验日期") =rs1("查验日期")
rs("放行日期") =rs1("放行日期")
rs("提单号") =rs1("提单号")
rs("件数") =rs1("件数")
rs("毛重") =rs1("毛重")
rs("备注") =rs1("备注")
rs("品名") =rs1("品名")
rs("操作员") =rs1("操作员")
rs("报关单号") =rs1("报关单号")
rs("整拼散") =rs1("整拼散")
rs("通关单号") =rs1("通关单号")
rs("联系人") =rs1("联系人")
rs("电话") =rs1("电话")
rs("手机") =rs1("手机")
rs("传真") =rs1("传真")
rs("地址") =rs1("地址")
rs("邮编") =rs1("邮编")
rs.Update

end if

rs1.MoveNext
wend

rs.Close
set rs=nothing
rs1.Close
set rs1=nothing

%>
...全文
31 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
darkbao 2002-09-17
  • 打赏
  • 举报
回复
<%
dim sql,rs,conn
dim sql1,rs1,conn1
dim sql2,rs2,conn2

Set conn = Server.CreateObject("ADODB.Connection")
Set conn1= Server.CreateObject("ADODB.Connection")
connstr = "DBQ=" + server.mappath("trans_order.mdb") + ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
connstr1 = "DBQ=" + server.mappath("update1.mdb") + ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
conn.Open connstr
conn1.Open connstr1

set rs=server.createobject("adodb.recordset")
set rs2=server.createobject("adodb.recordset")
set rs1=server.createobject("adodb.recordset")

dim yewuid
yewuid=0

sql1="select * from update1"
rs1.Open sql1,conn1,1,3
if not rs1.eof then
do while not rs1.eof
temp1=rs1("业务流水号")
t1=rs1("部门简称")
t3=rs1("进口日期")
t4 =rs1("卸货地点")
t5 =rs1("客户自编号")
t6 =rs1("客户简称")
t7 =rs1("经营单位")
t8 =rs1("运输工具")
t9 =rs1("接单日期")
t10 =rs1("查验日期")
t11 =rs1("放行日期")
t12 =rs1("提单号")
t13 =rs1("件数")
t14 =rs1("毛重")
t15 =rs1("备注")
t16 =rs1("品名")
t17 =rs1("操作员")
t18 =rs1("报关单号")
t19 =rs1("整拼散")
t20 =rs1("通关单号")
t21 =rs1("联系人")
t22 =rs1("电话")
t23 =rs1("手机")
t24 =rs1("传真")
t25 =rs1("地址")
t26 =rs1("邮编")

sql="select * from trans_order where 业务流水号='"&temp1&"'"
rs.Open sql,conn,1,3
if rs.eof and rs.bof then
sql2="update trans_order set 部门简称='"&t1&"',进口日期='"&t3&"',卸货地点='"&t4&"',客户自编号='"&t5&"',客户简称='"&t6&"',经营单位='"&t7&"',运输工具='"&t8&"',接单日期='"&t9&"',查验日期='"&t10&"',放行日期='"&t11&"',提单号='"&t12&"',件数='"&t13&"',毛重='"&t14&"',备注='"&t15&"',品名='"&t16&"',操作员='"&t17&"',报关单号='"&t18&"',整拼散='"&t19&"',通关单号='"&t20&"',联系人='"&t21&"',电话='"&t22&"',手机='"&t23&"',传真='"&t24&"',地址='"&t25&"',邮编='"&t26&"' where 业务流水号='"&yewuid&"'"
conn.execute (sql2)
else
rs.addnew
rs("部门简称") =t1
rs("进口日期") =t3
rs("业务流水号") =temp1
rs("卸货地点") =t4
rs("客户自编号") =t5
rs("客户简称") =t6
rs("经营单位") =t7
rs("运输工具") =t8
rs("接单日期") =t9
rs("查验日期") =t10
rs("放行日期") =t11
rs("提单号") =t12
rs("件数") =t13
rs("毛重") =t14
rs("备注") =t15
rs("品名") =t16
rs("操作员") =t17
rs("报关单号") =t18
rs("整拼散") =t19
rs("通关单号") =t20
rs("联系人") =t21
rs("电话") =t22
rs("手机") =t23
rs("传真") =t24
rs("地址") =t25
rs("邮编") =t26
rs.Update
end if
rs.close
rs1.MoveNext
loop
end if
set rs=nothing
rs1.Close
set rs1=nothing
conn.close
set conn=nothing
%>
darkbao 2002-09-17
  • 打赏
  • 举报
回复
楼上的错误。
1,3可以更新

楼主说出问题重点。
meetweb 2002-09-17
  • 打赏
  • 举报
回复
rs.Open sql,conn,1,3

这种方式是不能更新数据记录的,
请使用

rs.Open sql,conn,2,3
meetweb 2002-09-17
  • 打赏
  • 举报
回复
不能实现,是啥意思。程序应该没有错误呀。

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧