命名空间“System.Data"中不存在类型或命名空间名称“SQLite" [英] The type or namespace name 'SQLite' does not exist in the namespace 'System.Data'

查看:103
本文介绍了命名空间“System.Data"中不存在类型或命名空间名称“SQLite"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 C# 新手.我正在使用 Visual Studio 13,我的问题是它向我抛出了这个错误:

I am new with C#. I am using Visual Studio 13, my problem is that it's throwing me this error:

命名空间System.Data"中不存在类型或命名空间名称SQLite"(您是否缺少程序集引用?)

The type or namespace name 'SQLite' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)

是的,我从这里添加了引用 https://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki我从这里开始学习教程:https://www.youtube.com/watch?v=N0hL5sGkUSA

Yes, I added references from here https://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki and I followed the tutorial from here : https://www.youtube.com/watch?v=N0hL5sGkUSA

这是我的代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SQLite;

namespace PercobaanDulu
{
    public partial class Form1 : Form
    {
        string connString;
        public Form1()
        {
            InitializeComponent();

            connString = @" Data Source = C:\Users\Febry Fairuz\Desktop\dbDemoLagi.db; Version = 3";
        }

        private void btnConnect_Click(object sender, EventArgs e)
        {
           using (SQLiteConnection con = new SQLiteConnection(connString)) {
                try { 
                    con.Open();
                    if(con.State == ConnectionState.Open){
                        MessageBox.Show("Koneksi berhasil dengan SQLite");
                    }
                }catch(Exception ex){
                    MessageBox.Show(ex.Message);
                }
            } 
        }
    }
}

你能帮我吗?

推荐答案

我认为问题在于您引用的 System.Data.Sqlite.dll 版本与您正在使用的 .NET.您应该检查并安装 dll 的兼容版本以解决您的问题.

I think the problem is that you are referencing incorrect version of System.Data.Sqlite.dll which is not compatible with version of .NET which you are using. You should check and install the compatible version of the dll to get rid of your problem.

如果您使用的是 .Net 4.5,那么您可以尝试 NuGet 包 System.数据.SQLite.

If you are using the .Net 4.5 then you can try the NuGet package System.Data.SQLite.

软件包的直接链接是 这里

这篇关于命名空间“System.Data"中不存在类型或命名空间名称“SQLite"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆