Query failed: Incorrect string value

Post

Posted
Rating:
#1 (In Topic #1819)
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’
Hi Everyone,

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
Could someone smarter then myself show me where i have gone wrong please.

Attachment

RecipitNoVAT.txt

Kind Regards
Andy
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Enthusiast
Gianluigi is in the usergroup ‘Enthusiast’
I'll warn you right away, I'm a database novice.  :$
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.

:goodbye:
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Enthusiast
Gianluigi is in the usergroup ‘Enthusiast’
Only now, looking back at the code I posted (FindTestDiacritics), did I realize I forgot this title: Me.Caption = ("'DataSource Find' Errors on PostgreSQL & MySQL Databases - ") & MData.DataTitle
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.

:goodbye:
Online now: No Back to the top

Post

Posted
Rating:
#4
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’
Hi All,

I figured it I had to drop my exisiting that formati and change it to have UF8 encoding now I did that it works

 
Online now: No Back to the top
1 guest and 0 members have just viewed this.