菜鸟又有问题了,help me!高手。

etononline 2004-11-22 11:00:43
问题是这样的,数据库里有两个表,两个表里的字符段都是一样的。

怎么样才能把表一的数据放到表二里。

就是说,做一个提交窗口,按表里的一个字符段比如说日期date(2004-11-12),

输入提交日期就直接把相同日期的数据放到表二里了。
...全文
129 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
jingxiaoping 2004-11-23
  • 打赏
  • 举报
回复
数据表的路径是否正确?
etononline 2004-11-23
  • 打赏
  • 举报
回复
就日期和时间的字段,格试是短时间。
etononline 2004-11-22
  • 打赏
  • 举报
回复
如果表二不多加字段的话,一样可以提示数据重复提示吗?

还有就是可不可以把编号改为日期,直接提示日期(2004-11-21)数据操作成功!
jingxiaoping 2004-11-22
  • 打赏
  • 举报
回复
<!--
恐怕也得先打开表一,然后再把表一符合条件的内容复制或者是插入过去。
表2里面得附加一个字段,来表示表1的ID值,以免加入的内容重复
-->
<%
sdate=request.form("sdate") '此处的sdate为你输入的日期,日期千万要正确!
set rs=server.createobject("adodb.recordset")
'以下的操作得保证date也是2004-11-12的存储情况,不然就得把以下的语句修改为模糊查询
'rs.open "select * from tablename where date='%"&sdate&"%' order by id desc",cn,1,3 '此处为模糊查询
rs.open "select * from tablename where date='"&sdate&"' order by id desc",cn,1,3
if rs.recordcount<>0 then
'以下是默认该日期不止是1条记录时的操作
while not rs.eof
set temp=server.createobject("adodb.recordset")
'此处的oldid为表1的id
temp.open "select oldid from tablename1 where oldid="&rs("id"),cn,1,3
if temp.recordcount<>0 then
response.write "要插入的编号为"&rs("id")&"内容已经存在!<br>"
response.write "操作失败!<br>"
'如果在默认的情况下是更新的话,那么此处就要执行更新的语句
'sql="update tablename1 set xx=xx where xxx"
'cn.execute(sql)
else
'sql="insert into tablename1 (xxx) values (xxx) where xxx"
'cn.execute(sql)
response.write "编号为"&rs("id")&"的内容已经插入!<br>"
response.write "操作成功!<br>"
end if
rs.movenext
wend
end if
rs.close
set rs=nothing
cn.close
set cn=nothing
%>
etononline 2004-11-22
  • 打赏
  • 举报
回复
因为我写进和删除都是用的这个字段呀,为什么会出错呢?
jingxiaoping 2004-11-22
  • 打赏
  • 举报
回复
你存放日期的是什么类型的字段,是SQL连接符那里出现的错误。
etononline 2004-11-22
  • 打赏
  • 举报
回复
<%
addtime=request.form("addtime")
set rs=server.createobject("adodb.recordset")
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("db/db.mdb")
rs.open "select * from eton where addtime=#"&addtime&"# order by id desc",conn,1,3
if rs.recordcount<>0 then
while not rs.eof
rs.open "select addtime from eton1 where addtime=#"&rs("addtime")&"#",conn,1,3
if rs.recordcount<>0 then
response.write "操作失败!"
else
response.write "操作成功!"
end if
rs.movenext
wend
end if
rs.close
set rs=nothing
cn.close
set cn=nothing
%>
这是我的代码?
Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e10'

[Microsoft][ODBC Microsoft Access Driver] 参数不足,期待是 1。

/eton/index/add1.asp,行6
这句是错误。?
gu1dai 2004-11-22
  • 打赏
  • 举报
回复
你这个是倒换数据
应该是很简单的阿。
iuhxq 2004-11-22
  • 打赏
  • 举报
回复
一句insert into 就可以搞定
jingxiaoping 2004-11-22
  • 打赏
  • 举报
回复
把出现问题的全部错误提示贴一下。
etononline 2004-11-22
  • 打赏
  • 举报
回复
但是还是出现问题,不行呀。。。
jingxiaoping 2004-11-22
  • 打赏
  • 举报
回复
如果说表是ACCESS的话,那么就需要把连接串部分进行一下修改,将
rs.open "select * from eton where addtime='"&addtime&"' order by id desc",conn,1,3
改为
rs.open "select * from eton where addtime=#"&addtime&"# order by id desc",conn,1,3

rs.open "select addtime from eton1 where addtime="&rs("addtime"),conn,1,3
改为
rs.open "select addtime from eton1 where addtime=#"&rs("addtime")&"#",conn,1,3

SQLSERVER数据库中使用的是引号,你修改过来就可以使用了。
etononline 2004-11-22
  • 打赏
  • 举报
回复
还是没实现,看看我的代码如下:
<%
addtime=request.form("addtime")
set rs=server.createobject("adodb.recordset")
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("db/db.mdb")
rs.open "select * from eton where addtime='"&addtime&"' order by id desc",conn,1,3
if rs.recordcount<>0 then
while not rs.eof
rs.open "select addtime from eton1 where addtime="&rs("addtime"),conn,1,3
if rs.recordcount<>0 then
response.write "操作失败!<br>"
else
response.write "操作成功!<br>"
end if
rs.movenext
wend
end if
rs.close
set rs=nothing
cn.close
set cn=nothing
%>
addtime:为提交日期
eton:为表一
eton1:为表二
要实现的就是,把表一的数据写到表二里面。
而条件就是按日期来提交数据。
帮我看看那里出错了。。。。。
jingxiaoping 2004-11-22
  • 打赏
  • 举报
回复
除非你确保数据的单一性,也就是说2004-11-21这天只有这一条单独的信息。
可以提示日期数据操作成功,只需要把rs("id")改为日期的字段就行了。

28,390

社区成员

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

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