我想要上传了EXCEL文件,相应ID能够写入到字段中。
insert into   values 不支持where 怎么办,高手赐教,谢谢。<style>
body {
background-color:#cccccc;
font-size:12px;
}
</style>
<%
'开发:www.aspprogram.cn
'作者:wangsdong
'原创文件,请保留此信息
'友情下载,http://www.codefans.net
addok=request("addok")
if addok="" or isnull(addok) then
%>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
  <tr>
    <td height="25" colspan="2" align="center">文件上传</td>
  </tr>
  <form action="cg_cgjhanyadd.asp?addok=add" method="post" name="setup" id="setup">
  <tr>
    <td height="25" align="right">标题:</td>
    <td height="25"><input name="title" type="text" id="title"></td>
  </tr>
  <tr>
    <td width="25%" height="25" align="right">文件:</td>
    <td width="75%" height="25"><input name='path' type='text' id='path' value='' size='40' maxlength='255'>
      <input type="button" value="上传..." onClick="window.open('upload.asp?fuptype=pic&fupname=<%=replace(replace(replace(now(),"-",""),":","")," ","")%>&frmname=setup&bdname=path','_blank','scrollbars=yes,resizable=no,width=650,height=450')"></td>
  </tr>
  <tr>
    <td height="25" align="right">&nbsp;</td>
    <td height="25"><input type="submit" value="导入数据"></td>
  </tr>
  </form>
 
</table>
<%
end if
if addok="add" then
%>
<!--#include file="codefans_net.conn.asp"-->
<%
Set xlsconn = server.CreateObject("adodb.connection") 
set rs=server.CreateObject("adodb.recordset")source1=server.mappath("..")&"\"&replace(request("path"),"/","\")
myConn_Xsl="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &source1& ";Extended Properties=Excel 8.0"
xlsconn.open myConn_Xsl sql="select * from [导入$]"
set rs=xlsconn.execute(sql)
if not rs.eof then
while not rs.eof
id=rs("ID")
wlbm=rs("物料编码")
gys=rs("供应商1")
cgjftime=rs("交付日期1")
cgshuliang=rs("数量1")sql="insert into [cgyl](wlbm,gys,cgjftime,cgshuliang) values('"& wlbm &"','"& gys &"','"& cgjftime &"','"& cgshuliang &"') "
conn.execute(sql)rs.movenext
wendend if
response.write "导入成功"
end if
%>
<!---->

解决方案 »

  1.   

    你这不是没有用到where吗你要判断某些不要的话,就加个判断呗,加在组装sql语句之前
      

  2.   

    <form action="cg_cgjhanyadd.asp?addok=add" method="post" name="setup" id="setup">
    这里用post能上传成功吗?
      

  3.   

     
    happytonice:上传没问题Andrewsway:能不能花点时间帮我写下代码,谢谢。刚学不太懂。
      

  4.   

    你为什么不选择让HTML代码和逻辑处理代码分离呢??我没有勇气仔细找。
      

  5.   

    我想在insert into values 加上相当于where sql="insert into [cgyl](wlbm,gys,cgjftime,cgshuliang) values('"& wlbm &"','"& gys &"','"& cgjftime &"','"& cgshuliang &"') where id='"& ID &"'"就想达到这个目的,高手帮忙,刚学代码,谢谢。
      

  6.   


    先判断id吧,有就用update。
      

  7.   


    <!--#include file="codefans_net.conn.asp"-->
    <%
    Set xlsconn = server.CreateObject("adodb.connection")  
    set rs=server.CreateObject("adodb.recordset")source1=server.mappath("..")&"\"&replace(request("path"),"/","\")
    myConn_Xsl="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &source1& ";Extended Properties=Excel 8.0"
    xlsconn.open myConn_Xsl  sql="select * from [导入$]"
    set rs=xlsconn.execute(sql)
    if not rs.eof then
    while not rs.eof
    id=rs("ID")
    wlbm=rs("物料编码")
    gys=rs("供应商1")
    cgjftime=rs("交付日期1")
    cgshuliang=rs("数量1")if cgshuliang>0 and cgjftime>now and gys<>"" then
    sql="insert into [cgyl](wlbm,gys,cgjftime,cgshuliang) values('"& wlbm &"','"& gys &"','"& cgjftime &"','"& cgshuliang &"') "
    conn.execute(sql)
    end if
    rs.movenext
    wendend if
    response.write "导入成功"
    end if
    %>insert into楼主可以参考一下语句  :insert into del_main(ID,物料编码,供应商1,交付日期1,数量1)
    select 导入$.ID,导入$.物料编码,导入$.供应商1,导入$.交付日期1,导入$.数量1 
    from 导入$ where 导入$.ID=<100