linq TO sqlite

來源:互聯網
上載者:User
第一步:在http://code.google.com/p/dblinq2007/downloads/list上下載DbLinq2007,將 DbLinq.dll、DbLinq.Sqlite.dll、System.Data.SQLite.dll、 System.Data.SQLite.Linq.dll 四個檔案引入到項目中。

第二步:在cmd中執行DbMetal.exe,根據協助提示資訊輸入資料庫配置。
舉例:DbMetal.exe -c "DbLinqProvider=Sqlite;data source=test.db" --provider=Sqlite --database=testdb --code=testdb.cs(testdb.cs就是將要繼承DataContext的類檔案,testdb就是這個類名)

第三步:將產生好的檔案放到你的項目的DAL層中或者App_Code中,在aspx.cs或者form.cs檔案裡就可以調用了。
舉例:

C# code

SQLiteConnection con = new SQLiteConnection("DbLinqProvider=Sqlite;Data Source=test.db");
TestDb db = new TestDb(con);
GridView1.DataSource = db.TableName;
GridView1.DataBind();

注意:必須使用SQLiteConnection來建立資料庫連接,如果直接把連接字串放入建構函式的參數,很可能會報錯。

關於如何使用Sqlite資料庫的方法,我也講一下:
在 www.sf.net上下載SQLite Database Browser軟體,點“建立”指定資料庫所在目錄,命名為test.db3或者test.db都行,這個檔案就是資料庫了,然後利用SQLite Database Browser對test資料庫進行建表、加欄位、改資料類型等操作,很方便。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.