Using sqlite with .NET

The other day I found that there is a .NET wrapper for sqlite. sqlite is a very cool embeddable SQL-92 database engine. It's a single library that gives you a very fast, very scalable (2TB), single file, multi-user database. I thought the .NET wrapper is exceptionally handy because ADO is slow, and is hard to use (compared to this) and a HUGE overkill for smaller apps. It lets smaller apps have a real relational database without huge numbers of dependencies, complicated installs, or the complexity of ADO. Here is a really quick example program I wrote to try it out:

 System;
 System.Drawing;
 System.Collections;
 System.ComponentModel;
 System.Windows.Forms;
 System.Data;
 SQLite.NET;

 WindowsApplication2
{
    


      Form1 : System.Windows.Forms.Form
    {
         System.Windows.Forms.ListBox listBox1;
         System.ComponentModel.Container components = ;
         System.Windows.Forms.TextBox textBox1;
         System.Windows.Forms.Button button1;
         SQLiteClient db;

         Form1()
        {
            db =  SQLiteClient();
            InitializeComponent();
            UpdateList();
        }

          UpdateList()
        {
            SQLiteResultSet results;

            results = db.Execute();
            listBox1.Items.Clear();
            (ArrayList row in results.Rows)
            {
                listBox1.Items.Add(row[]);
            }
        }

           Dispose(  disposing )
        {
            ( disposing )
            {
                 (components != )
                {
                    components.Dispose();
                }
            }
            .Dispose( disposing );
        }


        



          InitializeComponent()
        {
            .listBox1 =  System.Windows.Forms.ListBox();
            .textBox1 =  System.Windows.Forms.TextBox();
            .button1 =  System.Windows.Forms.Button();
            .SuspendLayout();
            
            
            
            .listBox1.Location =  System.Drawing.Point(, );
            .listBox1.Name = ;
            .listBox1.Size =  System.Drawing.Size(, );
            .listBox1.TabIndex = ;
            
            
            
            .textBox1.Location =  System.Drawing.Point(, );
            .textBox1.Name = ;
            .textBox1.Size =  System.Drawing.Size(, );
            .textBox1.TabIndex = ;
            .textBox1.Text = ;
            
            
            
            .button1.Location =  System.Drawing.Point(, );
            .button1.Name = ;
            .button1.Size =  System.Drawing.Size(, );
            .button1.TabIndex = ;
            .button1.Text = ;
            .button1.Click +=  System.EventHandler(.button1_Click);
            
            
            
            .AutoScaleBaseSize =  System.Drawing.Size(, );
            .ClientSize =  System.Drawing.Size(, );
            .Controls.Add(.button1);
            .Controls.Add(.textBox1);
            .Controls.Add(.listBox1);
            .Name = ;
            .Text = ;
            .ResumeLayout();

        }


        


        [STAThread]
          Main()
        {
            Application.Run( Form1());
        }

          button1_Click(object sender, System.EventArgs e)
        {
            db.Execute( + textBox1.Text.Replace(,) + );
            UpdateList();
        }
    }
}
http://jclement.ca/devel/dotnet/sqlite.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值