Hi Syed,
No, I wanna use the "ADD" sql command to increase the quantity column as I
add on more quantity from the stock purchase. Is there a problem with the
below SQL statement ? Could someone out there help me to rewrite the codes?
Statement stmt = myConn.createStatement(); int rowsAffected =
stmt.executeUpdate("add Qtypurchase into IQty from item where ItemID=" +
ItemID4);
At 09:20 PM 11/25/2001 -0800, you wrote:
>Hi Richard,
>
>ItemID is a string variable and it is incorrect to
>assign it in this way.
>
>String sql = "SELECT * FROM ITEM WHERE ItemID="
>+ItemID;
>
>Here is the correct form
>
>String sql = "SELECT * FROM ITEM WHERE ItemID="
>+ItemID+"";
>
>I am sure that this will work.
>
>Hassan
>
>
>
>--- richardtham2001@y... wrote:
> > I wonder if anyone could help me to troubleshoot
> > this SQL coding on adding
> > a stock balance record in JSP:
> >
> > Below is an extract from my coding:
> >
> >
> > <html>
> > <head>
> > <title>Purchase A Stock Item</title>
> > </head>
> > <h1>Purchase A Stock Item</h1>
> > <body background="indtextb.jpg" bgcolor="#CCCCCC"
> > text="#000000"
> > link="#3366CC"
> > vlink="#666666" alink="#996600">
> > <table border="1" width="400">
> > <tr>
> > <td><b>Item ID</b></td><td><b>Item
> > Name</b></td>
> > <td><b>Item Ref</b></td><td><b>Vendor
> > ID</b></td> <td><b>Item
> > Cost</b></td> <td><b>Item
> >
> > Markup</b></td>
> > <td><b>Selling Price</b></td><td><b>Item
> > Quantity</b></td><td><b>Re-
> > order Quantity</b></td>
> >
> > <td><b>Description</b></td> <td><b>Action To
> > Perform</b></td>
> > </tr>
> >
> > <%@ page language="java" import="java.sql.*" %>
> >
> > <body>
> > <form action="idbpurchase.jsp">
> > <input name="ItemID" type="text" width="30">
> > <input type="submit" value="Enter A Item ID To
> > Purchase">
> > </form>
> >
> > <% String ItemID;
> > ItemID = request.getParameter("ItemID");
> >
> > if (ItemID == null) {
> >
> > %>
> >
> >
> >
> >
> > <%
> >
> > }
> >
> >
> > else
> >
> >
> >
> >
> > Class.forName("org.gjt.mm.mysql.Driver");
> >
> >
> > Connection myConn
> > DriverManager.getConnection("jdbc:mysql:///stock");
> >
> > Statement stmt = myConn.createStatement();
> >
> > String sql = "SELECT * FROM ITEM WHERE ItemID=" +
> > ItemID;
> >
> > ResultSet rs = stmt.executeQuery(sql);
> >
> >
> > if (rs != null) {
> >
> > while (rs.next()) {
> > String ItemID2 = rs.getString("ItemID");
> > String IName2 = rs.getString("IName");
> > String IRef2 = rs.getString("IRef");
> > String VendorID2 = rs.getString("VendorID");
> >
> > String ICost2 = rs.getString("ICost");
> > String IMarkup2 = rs.getString("IMarkup");
> > String ISellp2 = rs.getString("ISellp");
> > String IQty2 = rs.getString("IQty");
> >
> > String ReQty2 = rs.getString("ReQty");
> > String IDesc2 = rs.getString("IDesc");
> >
> >
> >
> > %>
> >
> > <tr>
> > <td><%= ItemID2 %></td>
> > <td><%= IName2 %></td>
> > <td><%= IRef2 %> </td>
> > <td><%= VendorID2 %> </td>
> >
> > <td><%= ICost2 %></td>
> > <td><%= IMarkup2 %></td>
> > <td><%= ISellp2 %> </td>
> > <td><%= IQty2 %> </td>
> >
> >
> > <td><%= ReQty2 %></td>
> > <td><%= IDesc2 %></td>
> >
> > <td><a href='imodproc2purchase.jsp?ItemID2=<%
> > ItemID2 %>'>confirm
> > purchase ?</a></td>
> >
> > </tr>
> >
> >
> > <%
> >
> > } /* of while */
> > } /* of if */
> >
> >
> > stmt.close();
> >
> >
> > myConn.close();
> > %>
> >
> > </table>
> >
> > </table>
> > <a href="icontrol.html">Go back to admin control</a>
> > </body>
> > </html>
> >
> >
> >
> >
> > ******************************************
> > <title>
> > Purchase A Stock Item
> > </title>
> > </head>
> > <%@ page language="java" import="java.sql.*" %>
> > <body>
> > <body background="indtextb.jpg" bgcolor="#CCCCCC"
> > text="#000000"
> > link="#3366CC"
> > vlink="#666666" alink="#996600">
> > <h1>Purchase A Stock Item</h1>
> > <form method="post" action="iupdpurchase.jsp">
> > <table border="1" width="400">
> >
> >
> > <tr>
> > <td><b>Quantity to Purchase:</b></td><td><input
> > name="Qtypurchase"
> > type="text"
> >
> > width="4"</td>
> >
> > </tr>
> >
> >
> >
> >
> >
> >
> > <%
> >
> > Class.forName("org.gjt.mm.mysql.Driver");
> >
> > Connection myConn
> > DriverManager.getConnection("jdbc:mysql:///stock");
> >
> >
> > Statement stmt = myConn.createStatement();
> >
> > %>
> >
> >
> > <tr>
> > <td colspan="2">
> > <center>
> > <input name="pagemode" type="hidden"
> > value="submit">
> > <input type="submit" value="Enter
> > Quantity To Purchase">
> > </center>
> > </td>
> > </tr>
> > <%
> > stmt.close();
> > myConn.close();
> > %>
> > </table>
> > </form>
> > <a href="icontrol.html">Go back to admin control</a>
> > </body>
> >
>=== message truncated ===
>
>
>=====
>Syed Hassan Javed
>
>__________________________________________________
>Do You Yahoo!?
>Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
>http://geocities.yahoo.com/ps/info1
>
>---
>Do you need true END-TO-END (e2e) Java Messaging (JMS)? Softwired
>offers industry's ONLY complete 100% JMS messaging solutions for your
>needs TODAY.
>Visit
>http://adtracking.wrox.com/track.asp?x=p2p%2Fe%2Fjava%2Dsoftwired&url=www.softwired-inc.com
>NOW and find
>out more!
>Our unique product range includes: iBus//Mobile (wireless data),
>iBus//MessageBus (IP Multicast), iBus//MessageServer (store and forward)
>and much more!
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com