How to get full value of a blob from sqlite - sqlite

I'm using SQLite Administrator to query a blob in a table. I'm using a query that looks like this:
SELECT quote(data) FROM versions WHERE id = '....'
The blob is longer than 256 characters. When I look at the results, I'm only getting the first 256 characters back.
The blob contains XML. How do I query the database so I get the full XML back?
Tony

I ended up writing a quick WinForms application to retrieve the data from the database and put it into a TextBox control. Thanks anyway.

Related

How can we insert an image in sqlite database(table)?

I guess that it's valid for MySQL, however, I cannot find anything about SQLite.
Basically, I have a table which is named 'CUSTOMER'.
So I create an attribute like this:
.. Image BLOB .. after that my insert statement looks like this:
INSERT INTO CUSTOMER(1,LOAD_FILE(D:/Project/Images/X.jpg));
However, the LOAD_FILE tag is not working and I don't know how to insert an image or if we can do that.
If you're using the sqlite3 shell, the relevant function is readfile().
If you're doing this from your own program, you have to read the file into a byte array and bind it as a blob to the desired column in an insert. The exact details vary depending on language and sqlite bindings, but you shouldn't ever have to convert it to a blob literal string and embed that directly into a statement.
You can store an image as a BLOB, but you'd have to insert it as a a series of bytes using something like :-
INSERT INTO CUSTOMER (image_column, other_column) VALUES(x'0001020304........','data for the first other column');
So you'd need to convert the file into a hex string to save it.
However, it's not really recommended to store images but to rather store the path to the image and then retrieve the file when you want to display/use the image.
Saying that, SQLite can, for smaller images (say 100K), actually be more efficient 35% Faster Than The Filesystem.
You must use the cmd command line (windows) to insert the attachment. The sqllitespy (version 1.9.13) does not support de command from the program command line.
You should acess you database first with the CMD and after that;
update (your table) set (column) = readfile ('dir where the files are stored'||num||ยด.jpg);

storing and retrieving large strings in SQLite with ADO and VBScript

I am using VBscript, ADO and the SQLite ODBC driver to store and retrieve large strings (~5KB). Storing them works fine, maybe because I am able to specify a size while I bind the parameters of the insert statement. When I try to retrieve those strings, however, I correctly get the first 256 (or 255) characters but the rest seams to come from a random memory area. What am I doing wrong (besides using VBscript and ADO...)?
I'm open to the idea of storing the text as binary data. But the functions I tried, to retrieve it later, didn't work.
getChunk will not work on a record field as noted on msdn, also the field attribute adFldLong states if getChunk can be used on that field.
In some fields you must use the SQL query to retrieve the length of data instead of using attribute actualSize
there is a good example e here http://kek.ksu.ru/eos/ecommerce/masteringasp/18-06.html

How to get Binary equivalent of BLOB data type in Oracle

I am using C# for front end and Oracle as a database. I have a BLOB type field in a table and is used to contain images. What I actually need to do is that whenever a record in table doesn't contain any image I want to show default pic for that particular record in front end. For that purpose can I get a binary format of that default image(without saving that image with a dummy record) after saving it temporarily in database, and then using that binary format in query to show default pic when the image doesn't exists for any record. What I am getting now is :
SELECT EMP_IMG FROM Employee_Master WHERE EMP_CODE = 1234
----------------------------------------------------------
(BLOB)
Look into byte[]; use Binary Serializer to get the byte[] version of the object.
See this: C# Object Binary Serialization

Using Full text search on varbinary data type for searching file contents

I create a full-text search index on varbinary(max) column and insert file content into this column.(files like docx,xlsx,txt,...) I create an extension column for specify content type.but when I query this table with contains,
SELECT *
FROM tblFiles
WHERE CONTAINS(tblFiles.FileContent, 'web OR webserver');
no result were showing.why?
You may need to wait a bit after defining a full text index, because the index itself is created in the background; it's an async process, not synchronous. For a small table it may not be noticeable, but for a large one, it will be.
Also, make sure the types in your file type column start with a dot: .docx instead of just docx.
I found why my query dont work. because files that inserted into db was docx and in my database does not exist any filter for this format.I inserted a doc document and query it.It works. :)
Thank you.

Can't store a korean string in database using LINQ

I'm using this code to store korean string in my database:
Dim username As String = Request.QueryString.Get("Some Korean String")
Using dg As New DataContext()
Dim newfriend As New FriendsTable With {.AskingUser = User.Identity.Name, .BeingAskedUser = username, .Pending = True}
dg.FriendsTables.InsertOnSubmit(newfriend)
dg.SubmitChanges()
end using
Checking my database, the username stored is a string"????"...
anybody got an idea how this happened or any workarounds?
What is your database collation? Are you able to store Korean strings with any other data access technology? What is the type of the username column, and is it accurately mapped in LINQ to SQL?
I suspect that something in the database isn't set up correctly to allow full Unicode. I very much doubt that this has anything to do with LINQ itself.
The other thing to check is that you're actually getting the right data in the first place. There are often several places where things can go wrong - you need to validate each place separately to see where the data is being corrupted. I have a short article on this which you may find helpful.
It sounds like you are storing Korean text in a varchar/text column which is not using a Korean collation. Thea easiest fix is to change the column type to nvarchar/ntext.
The nchar column types store Unicode data, whereas the char and varchar types store single byte characters in the specified collation.

Resources