Dear All,
I'm a new programmer using VB 2005 Professional and trying to auto increment the StyleNumber integer field by 1 every time I create a new product but this in not happening. What could I be doing wrong?
The table has the following fields?
CategoryID, CategoryName, StyleNumber
01A DRY FOODS 9 01B FRESH FOOD 4 02A BODY CARE PRODUCTS 3
the saving code is a follows:
Dim NRec As Integer
For NRec = 0 To CategoryTable.Rows.Count - 1
If CategoryTable.Rows(NRec).Item("CategoryName").ToSt ring = cboCategory.Text.ToString Then
StockCode = CSng(CategoryTable.Rows(NRec).Item("StyleNumber"))
Exit For
End If
Next
With CategoryCommand
.Connection = InventoryConnection
.CommandText = "UPDATE Category SET StyleNumber=StyleNumber+'" & 1 & "'WHERE CategoryID='" & cboCategory.SelectedValue.ToString & "'"
.ExecuteNonQuery()
End With
Please help me resolve this problem