Chixor (chixor1) wrote in vbdev,

Thanks and a New Question "Autoincrements?"

I want to thank you for the suggestions on my previous issues regarding combo boxes.
I decided to go with the visible/invisible option for 2 combo boxes, it was a lot easier to set up (for now).

Now I have a new question.
I have to add something to a database, which has an "orderNumber" which is a composite primary key.
Im not sure how my database would create the new order number or how to get my application to add the order number.
Here is the code I have so far-

'inserts the calculated order into tblPurchase
Me.TblPurchaseTableAdapter.Insert(txtProdID.Text, orderNum, prodQuantity, _
prodPrice, shipCost, salesTax, totalCost, Today)

'fills the dataset for the tblPurchase with data

Now someone suggeted I do this to fill in the order number:-

'retrieves the maximum current order number and increments it.
Dim orderNum As Int32 = Me.TblPurchaseTableAdapter.MaxOrderNum()
orderNum = orderNum + 1

But with my lack of knowledge on some of this, im not sure how to make/code a scalar query to the table adapter for the tblPurchase table that retrieves the maximum order number.

Any thoughts/suggestions on how I could do this?
  • Post a new comment


    default userpic

    Your IP address will be recorded 

  • 1 comment