未处理的异常:C#Sqlite

时间:2017-10-10 11:04:39

标签: c# sqlite

我刚开始使用SQLite。似乎看起来不像我使用的MySQL和SQL Server和MS Access。我在网上寻找了几个信息,我也找不到任何东西,我决定在这里发帖。

它连接良好,库存在于文件夹中,但是当我尝试插入数据库时​​,它会向控制台抛出异常。

我的代码看起来像这样

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Data.SQLite;

namespace sqliteInsert
{
    class Program
    {
        static void Main(string[] args)
        {
            string constring = "Data Source=C:\\Users\\DornellPC\\Desktop\\people_db.db;Version=3;New=False;Compress=True;";

            using (SQLiteConnection con = new SQLiteConnection(constring))
            {
                try
                {
                    string sql = "insert into people_data (first_name,last_name,tel,email) values ('Jack','Darwin','0966358936','j_darwin@fsmail.net')";
                    con.Open();
                    Console.WriteLine("Connection open!");

                    using (SQLiteCommand cmd = new SQLiteCommand(sql,con))
                    {
                        cmd.ExecuteNonQuery();
                        Console.WriteLine("Success!");
                        Console.ReadLine();
                    }
                }
                catch(Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
        }
    }
}

并且没有信息插入到数据库中,因为它会引发此异常:

  

未处理的异常:System.IO.FileNotFoundException:无法加载文件或ass embly'System.Data.SQLite,Version = 1.0.105.2,Culture = neutral,PublicKeyToken = db 937bc2d44ff139'或其依赖项之一。该系统找不到指定的文件。

     

在sqliteInsert.Program.Main(String [] args)

0 个答案:

没有答案
相关问题