table definition:
ORDER_ID (PK)| PRODUCT_ID | QTY | SUBTOTAL
Im trying to insert into table (ORDER_ID) values (aValue)
Code :
Dim mytransaction As OleDb.OleDbTransaction Dim orderid As String orderid = txt_orderid.Text myconnection2.Open() mytransaction = myconnection2.BeginTransaction Try Dim insertitem As String = "INSERT INTO TBL_ORDERITEM_A154287 (FLD_ORDER_ID) VALUES ('" & orderid & "')" Dim mywriter2 As New OleDb.OleDbCommand(insertitem, myconnection2, mytransaction) mywriter2.ExecuteNonQuery() mytransaction.Commit() myconnection2.Close() Beep() MsgBox("New order with Order Number : '" & orderid & "' has been successfully added.") Catch ex As Exception Beep() MsgBox("Problem with Transaction : " & vbCrLf & vbCrLf & ex.Message) mytransaction.Rollback() myconnection2.Close() End Try
i get "Problem with Transaction : You must eneter a value in the 'TABLE1234.PRODDUCT_ID' field" but i only want orderid. and i can't figure out why. is it because of the transaction? its a pk column? I did try adding extra fields and inserting those together with orderid, thought it was a one column issue thing.
the product's are actually in a listbox so im using for loop to insert into the table where orderid=orderid unless i can do that together with inserting orderid? im not sure how. coz i right now i have it setup as insert order id then update the table with the products. im sure that it the most complicated way but i dont know another way.
This post has been edited by noobydoods: 11 December 2016 - 12:37 AM