开发者

Garbled Text in uniqueidentifier in SQLite

开发者 https://www.devze.com 2023-01-16 18:46 出处:网络
Hi Dear All, I am having a problem using Sqlite with .Net/visual studio and need your help very much. The problem is:

Hi Dear All,

I am having a problem using Sqlite with .Net/visual studio and need your help very much.

The problem is:

I have garbled text in the ID column with data type 'uniqueidentifier' in Sqlite Database when viewing table data via some GUI tools (I try different tools)

It shows fine when retriving data in .net code, but just making me nervous on it.

More detail is here:

  1. Wh开发者_开发问答en I open the table with Sqlite Administrator, it show garbled text in the ID column.

  2. BUT, when I use visual design specified table data adaptor or general SqliteDataAdaptor to retrive the table, ID column shows fine.

Here is how I produce garbled data.

  1. First I drag and drop the table to visual studio dataset designer via the server explorer, using Sqlite connection driver dll.

  2. Modify the data programatically, then using the visual designed data adaptor to update it.

My suspection

I suspect that the SqliteDataAdaptor (or the .net adaptor inside?) insert UNICODE encoded string in the database. So when retriving data via the adaptor, it will shows fine. But the GUI tools can't handle unicode, so it shows garbled text?

Last

I don't know whether there's a 'uniqueidentifier' data type in Sqlite database. But on the database file I received from other colleges, it show the type as 'uniqueidentifier', and it seems that it is working.

Thank you all in advance.

Cheers


Never mind, I figured out the work around.

It seems like the Sqlite store the Guid as binary data by default. And .net want it to be string.

So set the connection string to the sqlite database with the follow settings will fix the problem:

Data source=somefile;BinaryGUID=False;

refer to: http://www.connectionstrings.com/sqlite

0

精彩评论

暂无评论...
验证码 换一张
取 消