標籤:sqlite string nload value csharp ems dispose connect cti
(1)下載SQLCE組件
https://www.microsoft.com/en-us/download/details.aspx?id=17876
(2)下載VS2013工具設計器
https://marketplace.visualstudio.com/items?itemName=ErikEJ.SQLServerCompactSQLiteToolbox
(3)用記事本建立一個空的文字檔。
(4)在View裡選擇“Server Explorer”,添加串連
(5)選擇SQL Server Compace4.0
(6)建立sdf檔案,例如放在 c:\db.sdf
(7)雙擊資料庫
(8)右鍵,可以建立表。
(9)串連SQLCE
SqlCeEngine engine = new SqlCeEngine(connString);engine.CreateDatabase();engine.Dispose();SqlCeConnection conn = new SqlCeConnection(connString);conn.Open();SqlCeCommand cmd = conn.CreateCommand();cmd.CommandText = "CREATE TABLE BlobTable(name nvarchar(128), blob ntext);";cmd.ExecuteNonQuery();cmd.CommandText = "INSERT INTO BlobTable(name, blob) VALUES (@name, @blob);";SqlCeParameter paramName = cmd.Parameters.Add("name", SqlDbType.NVarChar, 128);SqlCeParameter paramBlob = cmd.Parameters.Add("blob", SqlDbType.NText);paramName.Value = "Name1";paramBlob.Value = "Name1".PadLeft(4001);
在Visual Studio 2013裡使用 Microsoft SQL Server Compact Edition