We help IT Professionals succeed at work.
Get Started

MySQL TINYINT(1) error

768 Views
Last Modified: 2013-12-25
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

Comment
Watch Question
Top Expert 2008
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE