0

I'm having some problems with the UPDATE statement in VB.NET. Not the UPDATE statement directly, but when it comes to incrementing a field's value by 1.
Below is the code that I'm using for writing to the database, as well as the two UPDATE SQL statements that I've tried.

Any help would be appreciated...

Private Sub updateRecord(ByVal query As String)

        Dim connection As New MySqlConnection(connStr)
        Dim cmd As New MySqlCommand(query, connection)
        Dim rowsEffected As Integer = 0

        connection.Open()
        rowsEffected = cmd.ExecuteNonQuery()
        connection.Close()

    End Sub
UPDATE tblfirsthalf SET ShotsInsidePA = ShotsInsidePA + 1 WHERE PlayerNumber = 1
UPDATE `ontheball`.`tblfirsthalf` SET tblfirsthalf.ShotsInsidePA = tblfirsthalf.ShotsInsidePA +1 WHERE (((tblfirsthalf.PlayerNumber)=1));
3
Contributors
3
Replies
7
Views
6 Years
Discussion Span
Last Post by GeekByChoiCe
0

I see nothing wrong with your Update Statement.

Just for fun and games try:

UPDATE tblfirsthalf SET ShotsInsidePA = (ShotsInsidePA + 1) WHERE PlayerNumber = 1

And for more fun. Make sure ShotsInsidePA is not null

0

Just tried that too. Doesn't seem to be working either. Also, ShotsInsidePA isn't null either.

Not sure what the problem is... It seems to work perfectly well with every other SQL statement.

0

just a blue shot...
UPDATE tblfirsthalf SET ShotsInsidePA = CInt(ShotsInsidePA) + 1 WHERE PlayerNumber = 1

if im not mistaken the sql statement dont know the datatype of a field. so it takes by default string, which have different behave on a operator like +

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.