无法打开sqlite连接它要求“Dbconnecton” [英] cannot open sqlite connection it asking "Dbconnecton"

查看:200
本文介绍了无法打开sqlite连接它要求“Dbconnecton”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好...

我正在尝试使用此代码连接到sqlite

hi everyone...
i'm trying to connect to sqlite with this code

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

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        SQLiteConnection cn = new SQLiteConnection(@"data source=C:\Sqlite\bbbb.db");
        private void button1_Click(object sender, EventArgs e)
        {
            SQLiteCommand cmd = new SQLiteCommand("select  name from personn ", cn);
            cn.Open();
            SQLiteDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                string smd = (string)dr["name"].ToString();
                comboBox1.Items.Add(smd);
                
            }
            cn.Close();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            SQLiteCommand cmd = new SQLiteCommand("select carnumb from personn where name ='" + comboBox1.Text + "' ", cn);
            cn.Open();
            SQLiteDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                string smd = (string)dr["carnumb"].ToString();
                textBox1.Text = smd;
            }
            cn.Close();
        }
    }
}



但是当我运行它时我收到此错误

[ System.Data.Common.DbConnection类型在未引用的程序集中定义。你必须添加对程序集'System.Data,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089]

的引用,并在搜索之后做一些我可以解决的问题是添加引用system。数据

我已经添加了它...

即时通讯使用visual studio 2008

用于创建Windows移动应用程序和

net-framework 3.5

任何类型的帮助都会很受欢迎


but when i run it i'm getting this error
[The type 'System.Data.Common.DbConnection' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]
and after search and do what i can some solution was adding reference "system.data"
that i have already added it...
im using visual studio 2008
for creating windows mobile application and
net-framework 3.5
any type of help will be so appreciated

推荐答案

你应该使用这个程序集来添加对这个程序集的引用参考选项卡。右键单击Reference,选择Add Reference,然后(在为您打开的新窗口中)选择所需的程序集;在您的情况下 System.Data ,版本为 2.0.0.0 。 (确保您的系统中存在此内容; 已安装



然后您应该(首先)清理项目,然后使用项目中的新资源和程序集重新构建项目。
You should add the reference to this assembly using the Reference tab. Right click Reference, select Add Reference and then (in the new window that opens up for you) select the assembly that is required; in your case System.Data with version of 2.0.0.0. (Make sure this is present on your system; installed)

Then you should (first) clean the project, then re-build the project with the new resources and assemblies in the project.


大家好..

i可以喜欢解决方案经过多大努力:)真的......

所以如果你们中的任何一个人经历过这个问题

所有你需要做的就是这个步骤...



1: - 下载这两个文件这是需要的sqlite设置

和这个这是二进制和dll文件

2: - 创建应用程序后,转到此文件

bin> compact framework>并添加system.data.sqlite.dll参考



3: - 现在转到解决方案属性并添加现有文件

添加此3文件(SQLite.Interop.066.DLL和SQLite.Interop.066.exp和

SQLite.Interop.066.lib)



4 : - 然后将所有这些文件更改为Build action to {Content}不要忘记plz并将复制目录更改为{copy always}



5:加你sqlite.db存在并重建你的应用程序...

这里你去
hi everyone ..
i could fond solution after to much effort :) really...
so if any one of you went through this issue
all you have to do is this steps...

1:- download those two file this is sqlite setup its needed
and this this is binary and dll file
2:- after you create your application go to this file
bin>compact framework > and add system.data.sqlite.dll reference

3:- now go to solution properties and add existing file
add this 3 file (SQLite.Interop.066.DLL and SQLite.Interop.066.exp and
SQLite.Interop.066.lib)

4:- then change all of those file to Build action to {Content} "do not forget plz" and change copy directory to {copy always}

5: add you sqlite.db to exist and rebuild your application ...
here you go


这篇关于无法打开sqlite连接它要求“Dbconnecton”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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