0

Hi Guys, I have also the same problem with waldis I want to increment the max barcode value by 1. Can you help and check my code what is wrong?, My problem was the same as Waldis_1. Thanks in advance for those whose going to help.

Private   Sub autogenerated_Barcode()
conItem.Close()
conItem.Open()

Dim number As Integer

PassCommand.Connection = Me.TimItemTableAdapter.Connection
If PassCommand.Connection.State = ConnectionState.Open Then
    PassCommand.Connection.Close()
End If
PassCommand.Connection.Open()
PassCommand.CommandText = ("Select MAX(Barcode) FROM timitem")
PassAdapter.SelectCommand = PassCommand
PassReader = PassCommand.ExecuteReader
PassReader.Close()
PassCommand.Connection.Close()

If IsDBNull(cmdItem.ExecuteScalar) Then
    number = "Barcode"
    TextBoxBarcode.Text = number
Else
    number = cmdItem.ExecuteScalar + 1
    TextBoxBarcode.Text = number
End If
cmdItem.Dispose()
conItem.Close()
conItem.Dispose()
End Sub
2
Contributors
1
Reply
30
Views
6 Months
Discussion Span
Last Post by Xavier_5
0

Have you tried to change:
number = cmdItem.ExecuteScalar + 1
into:
number = Int32.Parse(cmdItem.ExecuteScalar) + 1
?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.