C# 读取sqlite文件

class Program
    {
        static void Main(string[] args)
        {
            getsqliteData();
        }
        public static void getsqliteData()
        {
            SQLiteConnection cnn = new SQLiteConnection();
            cnn.ConnectionString = @"Data Source=D:\test.db";
            cnn.Open();

            string sql = "select * from table";
            SQLiteCommand cmd = cnn.CreateCommand();
            cmd.CommandText = sql;

            SQLiteDataReader reader = cmd.ExecuteReader();
            List<ImportInfo> infoList = new List<ImportInfo>();
            while (reader.Read())
            {
                ImportInfo info = new ImportInfo();
                var tempStr = reader.GetString(4);
                dynamic jsonInfos = JsonConvert.DeserializeObject(tempStr);
                var episode_title = jsonInfos.episode_title.ToString();
                var audio_file_name = jsonInfos.audio_file_name.ToString();
                var lrc_file_name = jsonInfos.lrc_file_name.ToString();
                infoList.Add(new ImportInfo() { data1 = data1, data2 = data2 });
            }
        }
    }
    public class ImportInfo
    {
        public string data1{ get; set; }
        public string data2{ get; set; }
    }

 

posted @ 2018-05-24 10:22  向萧  阅读(4256)  评论(0编辑  收藏  举报