日期:2014-05-17  浏览次数:20787 次

数据库插入操作成功,更新操作失败
Java code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<% request.setCharacterEncoding("gb2312"); %>
<%@ page contentType = "text/html; charset=gb2312" %>
<%@ page language="java" import="java.sql.*"%>
<%@ page language="java" import="java.text.*"%>
<%@ page language="java" import="java.util.*"%>
<jsp:useBean id="ConnDBSQLite" scope="page" class="bean.DBsqlite"/>
<jsp:useBean id="select" scope="page" class="bean.select"/>
<jsp:useBean id="delect" scope="page" class="bean.delect"/>
<jsp:useBean id="SI" scope="session" class="bean.StockIn"/>
<html>  
<head>
<meta http-equiv="Content-type" content="text/html; charset=gb2312" />  
<title>入库操作</title>  
</head>
<body topmargin="80"> 
<%
String name ="";
if(!session.isNew())
{
//    response.setContentType( "text/html; charset=gb2312");
    name=(String)session.getAttribute("username");
    if(name==null)
        name="";
}
    String aa=request.getParameter("StockInNumber");
    int Si_Number = Integer.parseInt(aa);
    String date=new SimpleDateFormat("yyyy.MM.dd").format(Calendar.getInstance().getTime());

    String SIName=SI.getSIName();    
    String SIPrice=SI.getSIPrice();
    int Si_Price = Integer.parseInt(SIPrice);
    int Si_Money = Si_Number*Si_Price;
    String SIMoney = Integer.toString(Si_Money);

    String SISupName=SI.getSISupName();
    String SIstorehouse=SI.getSIstorehouse();

String sql="insert into StockIn(SiId,SiName,SiNumber,SiPrice,SiSupName,Sistorehouse,SiUser,SiTime,SiMoney)    VALUES(NULL,'"+SIName+"','"+Si_Number+"','"+SIPrice+"','"+SISupName+"','"+SIstorehouse+"','"+name+"','"+date+"','"+SIMoney+"') ";

    ConnDBSQLite.executeUpdate(sql);
%>
        <div align=center>
        <font size=5 color=red>
        商品入库表
        </font> 
        </div>
        <br><br><br>
    <table align=center  border width=1000>
            <tr>
                <th>商品名</th>
                <th>进货数量</th>                
                <th>进货价格</th>
                <th>供应商</th>
                <th>仓库</th>
                <th>操作员</th>
                <th>时间</th>
                <th>进货金额</th>
            <tr>
    <td align=center>
    <%=SIName%>
    </td>
    <td align=center>
    <%=Si_Number%>
    </td>
    <td align=center>
¥ <%=SIPrice%>
    </td>
    <td align=center>
<%=SISupName%>
    </td>
    <td align=center>
<%=SIstorehouse%>
    </td>
    <td align=center>
<%=name%>
    </td>
    <td align=center>
<%= date%>
    </td>
    <td align=center>
¥ <%= SIMoney%>
    </td>
    </table>
<%
                String siname=new String(SIName.getBytes("ISO-8859-1"),"gb2312");

                String upstno = "UPDATE stock SET StockNumber=5 where StockName=' "+siname+" ' ";

                delect.executeUpdate(upstno);    

%>
<script LANGUAGE='javascript'>alert("商品"+'<%=SIName%>'+"入库成功");</script>

    </table>
</body>
</html>


上面插入数据到表StockIn成功
结果更新库存表时stock出现问题,不报错,但是没有更新。
显然是
<%