Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Iam Creating a table : Username , Password
and insert 10 values in that table ..

i take windowsform application
.cs code is


C#
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 WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        string bhagyaraj;

        public Form1()
        {


            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            const string filename = @"E:\sqlite software";
            const string sql = "select * from tbuser;";
            var conn = new SQLiteConnection("Data Source=" + filename + ";Version=3;");
            try
            {
                conn.Open();
                DataSet ds = new DataSet();
                var da = new SQLiteDataAdapter(sql, conn);
                da.Fill(ds);
                grid.DataSource = ds.Tables[0].DefaultView;
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}




after that iam getting error in windowsform1.cs


Could not load file or assembly 'System.Data.SQLite, Version=1.0.94.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Posted
Updated 16-Sep-14 23:00pm
v4
Comments
OriginalGriff 17-Sep-14 1:54am    
And what is the error message?
harshavardhan12345678 17-Sep-14 3:00am    
hello sir ans my question
harshavardhan12345678 17-Sep-14 2:07am    
Error 2 The name 'grid' does not exist in the current context c:\users\srikanth\documents\visual studio 2012\Projects\WindowsFormsApplication3\WindowsFormsApplication3\Form1.cs 36 17 Sqlite

Try :
C#
grid.DataSource = ds.Tables[0];
 
Share this answer
 
Comments
harshavardhan12345678 17-Sep-14 2:08am    
Error 2 The name 'grid' does not exist in the current context c:\users\srikanth\documents\visual studio 2012\Projects\WindowsFormsApplication3\WindowsFormsApplication3\Form1.cs 36 17 Sqlite
Mehdi Gholam 17-Sep-14 2:15am    
Use the exact grid name i.e. grid1 etc., you can get it from the design view of your form.
harshavardhan12345678 17-Sep-14 2:23am    
now error is

Could not load file or assembly 'System.Data.SQLite, Version=1.0.94.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. An attempt was made to load a program with an incorrect format.
harshavardhan12345678 17-Sep-14 2:17am    
yeah i got it just now ... but didint connect to sqlite
If your query returns NO row, then reported line fails because ds.Tables is empty.
You have to handle such a case.
 
Share this answer
 
Comments
harshavardhan12345678 17-Sep-14 2:08am    
Error 2 The name 'grid' does not exist in the current context c:\users\srikanth\documents\visual studio 2012\Projects\WindowsFormsApplication3\WindowsFormsApplication3\Form1.cs 36 17 Sqlite
harshavardhan12345678 17-Sep-14 2:24am    
error is

Could not load file or assembly 'System.Data.SQLite, Version=1.0.94.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. An attempt was made to load a program with an incorrect format.

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