storing data in SQLite RRS feed

  • Question

  • Hello,

    I am complete noob in SQLite, and I would like to ask a question on how to store specific data in SQLite files.

    I've written some template code, but i dont seem to understand how exactly to implement what i want.

    Basically, i have a listbox with items, and 6 comboboxes that have numerical values and strings. I would like to store all this data in SQLite files so that I could later compare the results. 

    I would really appreciate if anyone could point out specifically how could I implement this in the following code :

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

    namespace WindowsFormsApplication1
        public partial class Form1 : Form
            private SQLiteConnection sql_con;
            private SQLiteCommand sql_cmd;
            private SQLiteDataAdapter DB;
            private DataSet DS = new DataSet();
            private DataTable DT = new DataTable();

            public Form1()

            private void SetConnection()
              sql_con = new SQLiteConnection("Data Source=file1.db;Version=3;New=False;Compress=True;");

            private void ExecuteQuery(string txtQuery)
                sql_cmd = sql_con.CreateCommand();
                sql_cmd.CommandText = txtQuery;


            private void button1_Click(object sender, EventArgs e)
                sql_cmd = sql_con.CreateCommand();
                string CommandText = "copy from textbox";
                DB = new SQLiteDataAdapter(CommandText, sql_con);
                DT = DS.Tables[0];
                Grid.DataSource = DT;



    This code was taken as a template, so it might be very wrong. 

    Thanks a lot!

    Tuesday, June 19, 2012 12:09 PM


All replies

  • Hi, 

    Are you facing any error? 

    Here is the examples shown how to work with SQLLite and ADO.Net

    Let us know if you face any issue. 

    If this post answers your question, please click "Mark As Answer". If this post is helpful please click "Mark as Helpful".

    • Edited by Kris444 Tuesday, June 19, 2012 2:19 PM
    Tuesday, June 19, 2012 2:17 PM
  • Hi Ivan

    Very nice tutorial on your web site. Unfortunately, I get this annoying compile error 

    Cannot implicitly convert type 'string' to 'System.Windows.Forms.DataGridViewTextBoxColumn' C:\Users\Nikotin\AppData\Local\Temporary Projects\WindowsFormsApplication1\Form1.Designer.cs

    and it points out to form1 code in Form1.Designer

    // Form1
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(468, 262);
                this.Name = "Form1"; <<<<<<<<<<<<<<<<<< error
                this.Text = "Form1";
                this.Load += new System.EventHandler(this.Form1_Load);

    Can you please point out what is the problem?

    Thank you!

    Tuesday, June 19, 2012 3:33 PM
  • Hi markis88 ,
    You have a Datagridview   which contains  a column named  “Name ” in your Form1 , am I right ?
    Please try to rename this columun  , and then  try to use “this.Name = "Form1";”again. I hope it is helpful to you .

    Check this link out to see some similar discussions :

    If you have any questions ,feel free to let me know .

    Lisa Zhu [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, June 20, 2012 5:29 AM