i want my order id to be autoincremented and stored in textbox and when i hit click, it gets stored in datagridview, so i can save my order in bulk from datagridview again.
my code have some issue
'i put this on formload (order page) Dim order As String Dim leftinv As String Dim rightinv As String Dim cmdorder As OleDbCommand = New OleDbCommand("SELECT * from order", con) Dim dsorder As New DataSet Dim daorder As New OleDbDataAdapter daorder.SelectCommand = cmdorder daorder.Fill(dsorder, "order") order = dsorder.Tables("order").Rows(0).Item("orderID") leftinv = Microsoft.VisualBasic.Left(order, 5) 'first 5 char is TESTS rightinv = leftinv & Format(Microsoft.VisualBasic.Right(order, 5) + 1, "00000") ' last five 00001 txtOrderID.Text = rightinv
my textbox gets executed properly. however when i hit the add button to add it to datagridview, instead of recording TESTS0002 it adds TESTS0003, and with each 'addbutton hit' the entire columns content of orderID gets the latestes incremented value.
how do i fix this?
also i would like to know THE CODE TO GET THE LAST NUMBER added to orderID field in order table.
in my add button code, i take the value of txtOrderID.text for the orderID column value