Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi everyone...
i'm trying to connect to sqlite with this code
C#
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();
        }
    }
}

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
Posted

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.
 
Share this answer
 
v2
Comments
jame01 4-Jul-15 2:58am    
hello dear Afzaal Ahmad Zeeshan your solution make me ride of that error and im so so grateful to you dear...
but after i Build it this error shows up so plz if you have any idea it will be so appreciated
the error is {The type 'System.ComponentModel.Component' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=2.0.0.0}
Afzaal Ahmad Zeeshan 4-Jul-15 10:27am    
Then in that case you need to repeat the process and add another assembly, "System" with version 2.0.0.0. :)

I would suggest that you try to target .NET framework 2, instead of 4 (or whatever you are trying to target).
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900