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
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.