大家好,
我在 .Net/Visual Studio 中使用 Sqlite 时遇到问题,非常需要您的帮助。
问题是:
当通过一些 GUI 工具查看表数据时,我在 Sqlite 数据库中数据类型为“uniqueidentifier”的 ID 列中出现乱码文本(我尝试了不同的工具),
在 . net 代码,但只是让我感到紧张。
更多详细信息在这里:
-
当我使用 Sqlite Administrator 打开表时,它在 ID 列中显示乱码文本。
-
但是,当我使用可视化设计指定表数据适配器或通用SqliteDataAdaptor来检索表时,ID列显示正常。
以下是我生成乱码数据的方法。
-
首先,我使用 Sqlite 连接驱动程序 dll,通过服务器资源管理器将表拖放到 Visual Studio 数据集设计器中。
-
以编程方式修改数据,然后使用可视化设计的数据适配器来更新它。
我的怀疑
我怀疑SqliteDataAdaptor(或里面的.net适配器?)在数据库中插入了UNICODE编码的字符串。因此,当通过适配器检索数据时,它会显示良好。但是GUI工具不能处理unicode,所以显示乱码?
最后
我不知道Sqlite数据库中是否有'uniqueidentifier'数据类型。但在我从其他大学收到的数据库文件中,它显示类型为“uniqueidentifier”,而且它似乎正在工作。
提前谢谢大家。
干杯
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:
-
When I open the table with Sqlite Administrator, it show garbled text in the ID column.
-
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.
-
First I drag and drop the table to visual studio dataset designer via the server explorer, using Sqlite connection driver dll.
-
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
发布评论
评论(1)
没关系,我已经找到解决办法了。
看起来 Sqlite 默认将 Guid 存储为二进制数据。 .net 希望它是字符串。
因此,使用以下设置将连接字符串设置为 sqlite 数据库将解决该问题:
Data source=somefile;BinaryGUID=False;
请参阅:http://www.connectionstrings.com/sqlite
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