Data Table Insert - SQL Error

tate

Centurion
Joined
Nov 10, 2003
Messages
116
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
 
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?
 
Back
Top