Avatar of pigparent
pigparent
 asked on

MySQL TINYINT(1) error

I am converting my application from using an Access backend to MySQL.  I am having to doctor some SQL statements here and there.  The one that has stumped me is in the snippet below.  I am trying to append a few records to a ew temporary table.  The value for the column "Reviewed" is -1 for the first record and zero for the second.  The error I keep getting is, "Out of range value adjusted for column 'Reviewed' at row 1".  Can you help me?
Dim sTempTable As String = sUserName & "ItemsDetail"
 
        Try
            If TableExists(sTempTable) Then
                Dim comm As New MySqlCommand("DROP TABLE " & sTempTable, con)
                If con.State = ConnectionState.Closed Then
                    con.Open()
                End If
                comm.ExecuteNonQuery()
                con.Close()
            End If
 
            If con.State = ConnectionState.Closed Then
                con.Open()
            End If
            Dim cmd As New MySqlCommand("CREATE TABLE invoicesdata." & sTempTable & " (PONo VARCHAR(50) NOT NULL, InvNo VARCHAR(50) NOT NULL, LineNo SMALLINT(5) UNSIGNED NOT NULL, EncumbrChange DOUBLE(15,5) NOT NULL, InvDate DATETIME NOT NULL, ProcessDate DATETIME NOT NULL, Reviewed TINYINT(1) UNSIGNED NOT NULL, Posted TINYINT(1) UNSIGNED NOT NULL) ENGINE = InnoDB", con)
 
            cmd.ExecuteNonQuery()
            cmd = New MySqlCommand("INSERT INTO invoicesdata." & sTempTable & " (PONo, InvNo, LineNo, EncumbrChange, InvDate, ProcessDate, Reviewed, Posted) SELECT Invoices.PONo, Invoices.InvNo, Invoices.ItemsLine AS LineNo, -InvoiceAmt AS EncumbrChange, Invoices.InvDate, Invoices.ProcessDate, Invoices.Reviewed, Invoices.Posted FROM(Invoices) WHERE (((Invoices.PONo)='" & sPONoPassed & "') AND ((Invoices.Exhibit)=0))", con)
            cmd.ExecuteNonQuery() '<-----this line throws the error
        Catch dbex As MySqlException
            MessageBox.Show("Cannot connect to the database.  Check the network status and try again.", "Data access error")
        Finally
            con.Close()
        End Try

Open in new window

Visual Basic ClassicMySQL Server

Avatar of undefined
Last Comment
pigparent

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Roger Baklund

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
pigparent

ASKER
I hadn't the foggiest notion what the system meant by signed and unsigned and you just cleared it up that quickly.  Thanks for helping this beginner without giving me a hard time for not seeing the obvious!
pigparent

ASKER
Thanks so much for your help and for your helpful attitude!  Have a great weekend.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes