tate Posted May 3, 2004 Posted May 3, 2004 Alright, I'm confused. I have an ItemMenu.aspx page that passes the value of ItemNum to my InsertItem.aspx page. Note that txtItemNum.Text is updated during the Page_Load event. I'm able to insert a new row into the "Items" table with the following SQL statement where ItemNum is hard coded; Sub Page_Load(Src As Object, E As EventArgs) strItemNum = Request.Form("ItemNum") txtItemNum.Text = strItemNum End Sub strSQL = "INSERT INTO Item (ItemNum, Description, ItemSuppNum, Cost, Price, UnitOfMeasure, OnHand) VALUES ('6668', '" & txtDescription.Text & "', '" & txtItemSuppNum.Text & "', " & dblCost & ", " & dblPrice & ", '" & txtUnitOfMeas.Text & "', " & intOnHand & ")" Now, when I try to use either of the variables strItemNum or txtItemNum in the following two SQL statements I get the same error; Error => Field 'Item.ItemNum' cannot be a zero-length string strSQL = "INSERT INTO Item (ItemNum, Description, ItemSuppNum, Cost, Price, UnitOfMeasure, OnHand) VALUES ('" & strItemNum & "', '" & txtDescription.Text & "', '" & txtItemSuppNum.Text & "', " & dblCost & ", " & dblPrice & ", '" & txtUnitOfMeas.Text & "', " & intOnHand & ")" strSQL = "INSERT INTO Item (ItemNum, Description, ItemSuppNum, Cost, Price, UnitOfMeasure, OnHand) VALUES ('" & txtItemNum.Text & "', '" & txtDescription.Text & "', '" & txtItemSuppNum.Text & "', " & dblCost & ", " & dblPrice & ", '" & txtUnitOfMeas.Text & "', " & intOnHand & ")" It appears I'm losing my value for some reason. Can anyone offer some advice? Thanks Tate Quote
Moderators Robby Posted May 3, 2004 Moderators Posted May 3, 2004 Don't use Request.Form to retreive values from a previous page, create properties or use the querystring.....here's a sample http://www.xtremedotnettalk.com/showthread.php?t=78434 Quote Visit...Bassic Software
tate Posted May 3, 2004 Author Posted May 3, 2004 Why do you suggest using the querystring instead of the request.form? From what I understand you can use either depending on which HTTP method used to submit the data. Request.Form requires POST while the querystring requires GET. In your experience is one better than the other? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.