C#ʹÓÃSQLiteÊý¾Ý¿â(asp.net/winform)
C#ʹÓÃSQLiteÊý¾Ý¿â(asp.net/winform)
2009Äê1ÔÂ7ÈÕ
ÆÀÂÛ
·¢±íÆÀÂÛ
SQLite
ÊÇÄ¿Ç°±È½ÏÁ÷ÐеÄÒ»¸ö¿ªÔ´¡¢Ãâ·ÑµÄСÐ͵ÄEmbeddable RDBMS(¹ØϵÐÍÊý¾Ý¿â)£¬ÓÃCʵÏÖ£¬ÄÚ´æÕ¼ÓýÏС£¬Ö§³Ö¾ø´óÊýµÄSQL92±ê×¼£¬¸ö±ð²»Ö§³ÖµÄÇé¿ö£¬ÔÚÕâÀï
˵Ã÷
¶Ô¸÷ÖÖÓïÑÔµÄÖ§³ÖÒ²±È½Ï²»´í£¬wrapperºÜ¶à¡£
Google
Gears ¡¢Mozilla
ºÍ Adobe AIR ¶¼ÔÚʹÓÃsqlite£¬Ó¦¸Ã˵Ã÷Æ仹ÊǺܲ»´íµÄ
SQLite µÄ¹Ø¼ü×ÖÁÐ±í£¬ÕâÀï
Ö§³ÖµÄsqlÓï·¨£¬ÔÚÕâÀï
ÔÚ .NET
ÀïÃæʹÓà SQLite
£¬ ÎÒÕâÀïʹÓõÄwrapperÊÇ System.Data.SQLite
£¬ËüÖ»ÐèÒªÒ»¸ödll,½Ó¿Ú·ûºÏADO.Net 2.0µÄ¶¨Òå,ÐÔÄÜÒ²²»´í,NHibernateÓõÄÒ²ÊÇËü£¬Ä¿Ç°Ö§³ÖADO.NET 3.5ÁË£¬Ö§³Ö¼¯³ÉÔÚ VS2005 ºÍ VS2008ÀïÃ棬¶øÇÒÖ§³Öwince£¬ÊǸöÁÁµã
ÒòΪ·ûºÏADO.NETµÄ¹æ·¶£¬ËùÒÔʹÓ÷½Ê½£¬»ù±¾ºÍ SqlClient
, OleDb
µÈÔÉúµÄÒ»ÖÂ
using System.Data;
using System.Data.SQLite;
//...
using (SQLiteConnection cn = new SQLiteConnection(
"Data Source=Test.db3;Pooling=true;FailIfMissing=false")
)
{
//ÔÚ´ò¿ªÊý¾Ý¿âʱ£¬»áÅжÏÊý¾Ý¿âÊÇ·ñ´æÔÚ£¬Èç¹û²»´æÔÚ£¬ÔòÔÚµ±Ç°Ä¿Â¼Ï´´½¨Ò»¸ö
cn.Open();
using (SQLiteCommand cmd = new SQLiteCommand())
{
cmd.Connection = cn;
//½¨Á¢±í£¬Èç¹û±íÒѾ´æÔÚ£¬Ôò±¨´í
cmd.CommandText = "CREATE TABLE [test] (id int, name nvarchar(20))";
cmd.ExecuteNonQuery();
//²åÈë²âÊÔÊý¾Ý
for (int i = 2; i < 5; i++)
{
cmd.CommandText = string.Format("INSERT INTO [test] VALUES ({0}, 'ÖÐÎIJâÊÔ')", i);
cmd.ExecuteNonQuery();
}
for (int i = 5; i < 10; i++)
{
cmd.CommandText = string.Format("INSERT INTO [test] VALUES ({0}, 'English Test')", i);
cmd.ExecuteNonQuery();
}
//¶ÁÈ¡Êý¾Ý
cmd.CommandText = "SELECT * from [test]";
using (SQLiteDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
{
while (dr.Read())
{
Console.WriteLine("µÚ{0} Ìõ£º{1}&q
Ïà¹ØÎĵµ£º
ǰ̨Éè¼ÆÒ³Ãæ.aspx
<body>
<form id="form1" runat="server">
<div>
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" />
</div>
  ......
Ö±½ÓÖØдRenderʼþ
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
StringWriter sw = new StringWriter() ;
&nb ......
ÍøÕ¾ÎļþÃû£º
1¡¢ ÍøÕ¾ÎļþÃûÒÔ±ê×¼Ó¢Îĵ¥´ÊÃèÊöÒµÎñÄÚÈÝ¡£Èç¹û1¸öÓ¢Îĵ¥´ÊÎÞ·¨ÃèÊö£¬¿ÉÒÔÔö¼Ó2¸ö»òÕß3¸ö£¬µ«¾¡Á¿ÎªÍêÈ«µ¥´Ê£¬ÀýÈçarticle.aspx/ articleView.aspx / articleList.aspx µÈ¡£
2¡¢ ÎļþÃû¾¡Á¿²»ÓÃÊý×ÖÃèÊö¡£
3¡¢ ÎļþÃû¾¡Á¿²»ÄÜÌ«³¤£¬ÒÔ²»³¬¹ý20¸ö×ÖĸΪÒË¡£
4¡¢ ͼƬÎļþÃû¾¡Á¿ÃèÊöÍ ......
·þÎñÆ÷¿Ø¼þ html±ê¼Ç
label----------<span/>
button---------<input type="submit"/>
textbox--------<input type="text"/>
linkbutton-----<a href="javascript:" />
imagebutton----<input type="image"/>
hyperlink------<a />
......