代码之家  ›  专栏  ›  技术社区  ›  Nikola Sivkov

适配器未使用SQLite C加载任何内容#

  •  0
  • Nikola Sivkov  · 技术社区  · 17 年前

    这是我的密码

     string dbfile = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName + "\\m23.db";
    
            string sql;
    
            DateTime dt = DateTime.Now;
            SQLiteConnection connection = new SQLiteConnection("datasource="+ dbfile);
    
            SQLiteDataAdapter adapter = new SQLiteDataAdapter("select * from p_posts", connection);
            DataSet data = new DataSet();
            adapter.Fill(data); //  <<< here i get the error
    
            SQLiteCommand cmd = new SQLiteCommand();
            cmd.CommandType = CommandType.TableDirect;
            cmd.Connection = connection;
    
            connection.Open();
    

    2 回复  |  直到 17 年前
        1
  •  1
  •   Jon Skeet    17 年前

    试用

    SQLiteConnection connection = new SQLiteConnection("Data Source=" + dbfile);
    

    这个 examples

        2
  •  0
  •   Nano Taboada    15 年前

    为了避免此类参数语法问题,您还可以考虑使用 SQLiteConnectionStringBuilder

    SQLiteConnectionStringBuilder con = new SQLiteConnectionStringBuilder();
    con.DataSource = dbfile;