Query failed: Incorrect string value
Posted
#1
(In Topic #1819)
Enthusiast

I have a slight puzzle on my hand I am getting the following error when I try to save some Plain text to the database
2025/10/10|00:24|Error ReceiptModule - SaveToRePrintTable - Query failed: Incorrect string value: '\xC4\xC4\xC4\xC4\xC4\xC4…' for column `posdatabase`.`receipt_table`.`receipt_nonVAT` at row 1
Attached to this post is the file i am trying to insert into the database and below is the code I used to create the table
Code (sql)
SQLCommand = NULL
SQLCommand &= "CREATE TABLE `receipt_table` ("
SQLCommand &= "`receiptdate` VARCHAR(10) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci', "
SQLCommand &= "`receipttime` VARCHAR(5) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci', "
SQLCommand &= "`receiptTransactionnumber` VARCHAR(10) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci', "
SQLCommand &= "`receiptcashier` VARCHAR(4) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci', "
SQLCommand &= "`receipt_nonVAT` LONGTEXT NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci', "
SQLCommand &= "`receipt_VAT` LONGTEXT NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci'"
SQLCommand &= ") "
SQLCommand &= "COMMENT ='This TABLE holds ALL the PoS recipit it has created AND they can be reprinted via the PoS Screen' "
SQLCommand &= "COLLATE ='utf8mb4_general_ci' " SQLCommand &= "ENGINE = InnoDB;"
Try Global.$DBLocalConnection.Exec(SQLCommand)
IF Error THEN
Message.Title = Global.ApplicationTitle
SystemFunctions.PCSpeakerBleep(1000)
Message.Info(Error.Text)
LogModule.ErrorLog("Error CreateNewTables - AddNewTable_RePrintReceiptTable - " & Error.Text)
ELSE
DisplayMesage = NULL
DisplayMesage &= "[b]COMPLETED[/b]"
SystemFunctions.PCSpeakerBleep(1000)
Message.Title = Global.ApplicationTitle
Message.Info(DisplayMesage)
END IF
SQLCommand &= "CREATE TABLE `receipt_table` ("
SQLCommand &= "`receiptdate` VARCHAR(10) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci', "
SQLCommand &= "`receipttime` VARCHAR(5) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci', "
SQLCommand &= "`receiptTransactionnumber` VARCHAR(10) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci', "
SQLCommand &= "`receiptcashier` VARCHAR(4) NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci', "
SQLCommand &= "`receipt_nonVAT` LONGTEXT NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci', "
SQLCommand &= "`receipt_VAT` LONGTEXT NULL DEFAULT NULL COLLATE 'utf8mb4_general_ci'"
SQLCommand &= ") "
SQLCommand &= "COMMENT ='This TABLE holds ALL the PoS recipit it has created AND they can be reprinted via the PoS Screen' "
SQLCommand &= "COLLATE ='utf8mb4_general_ci' " SQLCommand &= "ENGINE = InnoDB;"
Try Global.$DBLocalConnection.Exec(SQLCommand)
IF Error THEN
Message.Title = Global.ApplicationTitle
SystemFunctions.PCSpeakerBleep(1000)
Message.Info(Error.Text)
LogModule.ErrorLog("Error CreateNewTables - AddNewTable_RePrintReceiptTable - " & Error.Text)
ELSE
DisplayMesage = NULL
DisplayMesage &= "[b]COMPLETED[/b]"
SystemFunctions.PCSpeakerBleep(1000)
Message.Title = Global.ApplicationTitle
Message.Info(DisplayMesage)
END IF
RecipitNoVAT.txt
Andy
Posted
Enthusiast

You could try using the gb.db2 DB class, as per the example attached here:
Problems with Buscar with Gambas in SQLite3 - Gambas ONE
I mean, you could try creating the table using the technique used in the test and see if it still gives you the error.
If so, the cause could be a different character set; you could try converting them.
Posted
Enthusiast

This is because I used this example to report a bug to Minisini.
Ignore it, and I'm sorry; it should now work fine on all databases.
Posted
Enthusiast

I figured it I had to drop my exisiting that formati and change it to have UF8 encoding now I did that it works
1 guest and 0 members have just viewed this.




