【问题标题】:Read Guid stored as binary from Sqlite database从 Sqlite 数据库中读取以二进制形式存储的 Guid
【发布时间】:2011-11-15 10:10:02
【问题描述】:

在我的 C# 程序中,我需要使用 DataReader 从存储为 bianries 的 Sqlite 数据库中检索 Guid。

我尝试了以下代码,但未能将 ClassId 转换为 Guid。

using (IDataReader dataReader = DatabaseConnection.ExecuteReader(_getFileCountByClassCommand, new Dictionary<string, object>()))
         {
            while(dataReader.Read())
            {

               string str = Convert.ToString(dataReader["ClassId"]);
               fileCount.Add(new Guid(str), (int)dataReader["FileCount"]);
            }
         } 

有人知道怎么做吗?谢谢,

【问题讨论】:

    标签: c# sqlite


    【解决方案1】:

    您是否尝试过使用SqlDataReader.GetGuid

    您无需转换为 string 并再次转换回 Guid

    【讨论】:

      猜你喜欢
      • 2015-01-14
      • 2015-04-15
      • 1970-01-01
      • 1970-01-01
      • 2021-11-05
      • 1970-01-01
      • 2021-11-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多