Jump to content

Why SQLite show display data like 0xD34C2334..?


Recommended Posts

My data table is:

1.thumb.png.7c63763f2cdbf855ff75eb5c0765

But when i run this script to insert to my listview:

.....
_SQLite_Query($dbntdh, "SELECT * FROM data;", $qre)
While _SQLite_FetchData($qre, $qrow) = $SQLITE_OK
    GUICtrlCreateListViewItem(_ArrayToString($qrow, "|"),$gui_ntdh_listtu)
WEnd
.....

He does not show me the texts, he show me the code, i don't know how to convert it to text, please help me:

2.thumb.png.23ec50263e75e1da8b0a2ab2471c

I see the ID in column "STT" is good, but all other column text is not good. Thanks for your advanced helping!

Link to comment
Share on other sites

It all looks like that data was stored as binary.

What is the result of:

select distinct typeof(Từ) from data;

(please check that I spelled the column name correctly!). Are you getting BLOB somewhere?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to comment
Share on other sites

Maybe it stored data as binary, because i use this code to store data:

$currentTime = _Date_Time_SystemTimeToDateTimeStr(_Date_Time_GetSystemTime(), 1)
_SQLite_Exec($dbntdh, "INSERT INTO data (word, mean,time) VALUES ("&_SQLite_Encode($translated[0])&", "&_SQLite_Encode($translated[1])&", "&_SQLite_Encode($currentTime)&");")

When i use your code:

_SQLite_Query($dbntdh, "SELECT distinct typeof(word) FROM data;", $qre)

--->>> He return BLOB

So what should i do know, should i change the store code, or anything else to get BLOB data to display as text.

Link to comment
Share on other sites

Thanks for your suggestion, i think he store data as binary, so i use the autoit function BinaryToString to translate it to text as what i want to display:

_SQLite_Query($dbntdh, "SELECT * FROM data;", $qre)
While _SQLite_FetchData($qre, $qrow) = $SQLITE_OK
  GUICtrlCreateListViewItem(BinaryToString($qrow[0], 4)&"|"&BinaryToString($qrow[1], 4)&"|"&BinaryToString($qrow[2], 4)&"|"&BinaryToString($qrow[3], 4),$gui_ntdh_listtu)
WEnd

Thanks so much, love you so much ! !:thumbsup:

Link to comment
Share on other sites

You should have used _SQLite_FastEscape() instead of _SQLite_Encode(). See help to understand the difference.

Rather than having leaving the data in a wrong format, I highly recommend changing its type definitely. Make a copy of the DB just in case and apply this:

update data set word = cast(word as text);
update data set mean = cast(mean as text);
update data set time = cast(time as text);

Double check that the vietnamese text is OK after that!

Note that you can also use SQLite faster internal functions to format the ouput to your needs, simplifying AutoIt code:

_SQLite_Query($dbntdh, "SELECT word || '|' || mean || '|' || time FROM data;", $qre)
While _SQLite_FetchData($qre, $qrow) = $SQLITE_OK
    GUICtrlCreateListViewItem($qrow[0], $gui_ntdh_listtu)
WEnd
Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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