不支持关键字:'版本'

Pio*_*nom 3 c# sqlite wpf

我在VS2010中编写的这个项目是一个WinForms项目.我不是在VS2012中将其作为WPF项目编写的.我有一个引用的DLL(DailyReport).里面DailyReport是一个叫做的方法GetUniqueDates().它看起来像这样:

    public List<string> GetUniquesDates()
    {
        var dates = new List<string>();

        const string query = "SELECT date FROM hdd_local_data_v1_2";

        try
        {
            // Exception here  on the connection creation
            using (var connection = new SqlConnection(ConnectionStringFile)) 
            {
                using (var command = new SqlCommand(query, connection))
                {
                    connection.Open();

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            for (var i = 0; i < reader.FieldCount; i++)
                            {
                                dates.Add(reader.GetValue(i).ToString());
                            }
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {         
            Logger.Error(ex.Message);
        }

        dates.Sort();

        return dates.Distinct().ToList();
    }
Run Code Online (Sandbox Code Playgroud)

ConnectionStringFile设置在构造函数,如下所示:

ConnectionStringFile = @"Data Source=C:\hdd_data\Rubicon.hdd;Version=3;New=False;Compress=True;";
Run Code Online (Sandbox Code Playgroud)

现在,在我的VS2010 WinForms项目中,这种方法运行得很好.但是,在我的VS2012 WPF项目中,我得到了一个例外,我在上面提到过.例外是:

keyword not supported 'version'.
Run Code Online (Sandbox Code Playgroud)

该数据库是SQLite数据库.我试过删除version关键字,但后来我得到了例外:

keyword not supported 'new'.
Run Code Online (Sandbox Code Playgroud)

我的问题是:为什么连接在我的WinForms项目中工作而不是我的WPF项目?处理数据库连接时是否有变化?

此外,请注意,这不是关于参数化查询等的问题.所以,如果可能的话,请将这些评论告诉自己.谢谢.

Pio*_*nom 10

我遇到的问题是因为我试图创建一个SqlConnection而不是一个SQLiteConnection.做出改变解决了我的问题.