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
Ïà¹ØÎĵµ£º
¹ØÓÚC#ÖÐtimerÀà ÔÚC#Àï¹ØÓÚ¶¨Ê±Æ÷Àà¾ÍÓÐ3¸ö
1.¶¨ÒåÔÚSystem.Windows.FormsÀï
2.¶¨ÒåÔÚSystem.Threading.TimerÀàÀï
3.¶¨ÒåÔÚSystem.Timers.TimerÀàÀï
System.Windows.Forms.TimerÊÇÓ¦ÓÃÓÚWinFormÖеģ¬ËüÊÇͨ¹ýWindowsÏûÏ¢»úÖÆÊµÏ ......
#(¶Á×ö "C sharp")ÊÇ΢Èí¹«Ë¾ÔÚÈ¥ÄêÁùÔ·¢²¼µÄÒ»ÖÖеıà³ÌÓïÑÔ,²¢¶¨ÓÚÔÚ΢ÈíÖ°Òµ¿ª·¢ÕßÂÛ̳(PDC)ÉϵÇ̨ÁÁÏà.C#ÊÇ΢Èí¹«Ë¾Ñо¿Ô±Anders HejlsbergµÄ×îгɹû.C#¿´ÆðÀ´ÓëJavaÓÐמªÈ˵ÄÏàËÆ;Ëü°üÀ¨ÁËÖîÈçµ¥Ò»¼Ì³Ð,½çÃæ,ÓëJava¼¸ºõͬÑùµÄÓï·¨,ºÍ±àÒë³ÉÖмä´úÂëÔÙÔËÐеĹý³Ì.µ«ÊÇC#ÓëJavaÓÐ×ÅÃ÷ÏԵIJ»Í¬,Ëü½è¼øÁËDelphiµÄÒ»¸ ......
asp.net´°ÌåµÄ´ò¿ªºÍ¹Ø±Õ
//´ò¿ªÐµĴ°Ìå
Response.Redirect("WebMain.aspx");
//µ¯³öÒ»¸öд°Ìå
Response.Write("<script>window.open(\"WebMain.aspx\")</script>")
//µ¯³öÒ»¸öÖ»ÓÐÈ·¶¨°´Å¥µÄÌáʾ¿ò
Response.Write("<script>alert(\"Óû§Ãû»òÃÜÂë´íÎó\");</script>") ......
protected void Button6_Click(object sender, EventArgs e)
{
this.Label11.Text = HtmlEncode(this.TextBox3.Text);
}
protected static string HtmlEn ......