Jump to content

Error n. 3 on _SQLite_QuerySingleRow


Recommended Posts

Good morning everyone :) I'm having this error and I don't know why...
 

Func PrelevaProdotto()
    Local $sProdottoDaCercare, $iQuantitaProdotto, $iQuantitaProdottoDaPrelevare, $aRisultato, $iRighe, $iColonne, $aRiga
    $sProdottoDaCercare = GUICtrlRead($input_RicercaProdotto)
    If($sProdottoDaCercare = "") Then
        MsgBox($MB_ICONERROR, "Errore!", "Inserisci un codice prodotto per continuare!")
        GUICtrlSetState($input_RicercaProdotto, $GUI_FOCUS)
    Else
        If(_SQLite_QuerySingleRow($hDatabase, "SELECT QUANTITA, DESCRIZIONE FROM Gestione_Magazzino WHERE BARCODE = " & _SQLite_FastEscape($sProdottoDaCercare) & ";", $aRiga) = $SQLITE_OK) Then
            _ArrayDisplay($aRiga)
            ; Se il prodotto non viene trovato nel database, allora...
            If($aRiga[0] = "") Then
                    MsgBox($MB_ICONERROR, "Errore!", "Il prodotto con Barcode = '" & $sProdottoDaCercare & "' " & @CRLF & "non è stato trovato nel Database.")
                ; ... altrimenti...
                Else
                    $iQuantitaProdotto = $aRiga[0]
                    $iQuantitaProdottoDaPrelevare = InputBox("Preleva Prodotto: ", "Prodotto: " & $aRiga[1] & @CRLF & "Quantità attuale: " & $iQuantitaProdotto & @CRLF & @CRLF & _
                                                                                     "Inserire il quantitativo del prodotto da prelevare: " & _
                                                                                     @CRLF, "", "", 150, 200, @DesktopWidth/2 - 50, @DesktopHeight/2 - 100)
                    If(@error) Then ; Error Checking!
                        Switch(@error)
                            Case 1
                                MsgBox($MB_ICONINFORMATION, "Informazione:", "Operazione annullata dall'utente.", 2)
                            Case 2
                                MsgBox($MB_ICONINFORMATION, "Informazione:", "Timeout InputBox raggiunto.", 2)
                            Case 3
                                MsgBox($MB_ICONERROR, "Errore!", "Errore durante l'apertura dell'InputBox." & @CRLF & "Errore: " & @error)
                            Case 4
                                MsgBox($MB_ICONERROR, "Errore!", "Impossibile mostrare la InputBox su nessun monitor." & @CRLF & "Errore: " & @error)
                            Case 5
                                MsgBox($MB_ICONERROR, "Errore!", "Parametri InputBox invalidi." & @CRLF & "Errore: " & @error)
                        EndSwitch
                    Else
                        If($iQuantitaProdottoDaPrelevare = 0) Then
                            MsgBox($MB_ICONINFORMATION, "Informazione:", "Nessun prodotto prelevato dal Database.", 3)
                        Else
                            Local $sDataOraPrelievo = @HOUR & ":" & @MIN & ":" & @SEC & " - " & @MDAY & "/" & @MON & "/" & @YEAR
                            If(_SQLite_Exec($hDatabase, "UPDATE Gestione_Magazzino SET QUANTITA = QUANTITA - " & $iQuantitaProdottoDaPrelevare & ", " & _
                                                        "DATA_PRELIEVO = " & _SQLite_FastEscape($sDataOraPrelievo) & " " & _
                                                        "WHERE BARCODE = " & _SQLite_FastEscape($sProdottoDaCercare) & ";") = $SQLITE_OK) Then
                                $iQuantitaProdotto-=$iQuantitaProdottoDaPrelevare
                                MsgBox($MB_ICONINFORMATION, "Informazione:", "Prodotto " & @CRLF & "'" & $aRiga[1] & "'" & @CRLF & "prelevato con successo!" & @CRLF & "Quantità attuale: " & $iQuantitaProdotto, 2)
                            EndIf
                        EndIf
                    EndIf
                EndIf
                Else

                MsgBox($MB_ICONERROR, "Errore!", "Errore: " & @error)
                EndIf
    EndIf
EndFunc

What this function does:

  1. Read an input from a GUI and check if it is blank; if it is, prompt an error message to the user;
  2. Else, do a query which retrieve the quantity and the description of the product that has been searched in the warehouse: if the query retrieve an empty row, prompt an error message to the user, else, store the quantity of the product searched in a variable ( $iQuantitaProdotto ), showing an input box from where the user could write the quantity to withdraw from the warehouse of that product...
  3. Check if the quantity that the user typed is not 0: if it isn't, update the row of the product searched before, and show the successful operation :) 

Can someone please explain to me why that error? Thank you and have a good day :) 

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

BUMP :)

EDIT:

Referred to the previous post, should I select only 1 column from the table? The error is generated when I insert something that it's not in the database...

EDIT 2:

I managed with:
 

_SQLite_GetTable2d()

 

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...