顯示具有 SQL 標籤的文章。 顯示所有文章
顯示具有 SQL 標籤的文章。 顯示所有文章

2012年8月12日 星期日

[MS SQL] Performance counter registry hive consistency check

To avoid meet the problem again, I memo the solution here.

While installing SQLServer 2008 on Windows 7 64bit - Traditional Chinese Version.
I got an error message told me "Performance counter registry hive consistency check".
It would not happen on English version OS.
Here is an article will help.
http://www.dotblogs.com.tw/lastsecret/archive/2010/06/14/15865.aspx

In addition, you should execute window update to download Visual Studio 2008 sp1 if you like to install SQL Server 2008 Management Studio. Otherwise you'll got error message as "Another version of Microsoft Visual Studio 2008 has been detected on this system that must be updated to SP1.  Please update all Visual Studio 2008 installations to SP1 level, by visiting Microsoft Update."



2011年12月16日 星期五

[SQLite] Truncate table

In SQL server or mysql, you can delete all data from a table and set auto-increment identity to zero by the command below:

TRUNCATE TABLE [TableName];

In SQLite, there is no command for truncate tables, you should remove data and set identity by yourself.

DELETE FROM  [TableName]; 
UPDATE sqlite_sequence SET seq=0 WHERE name=' TableName'; 

2011年12月13日 星期二

[.Net] Create SQLite database and datatable with .net framework

This is sample code for creating a new database file and table in SQLite.

            string m_dataSource = "test1.s3db";
            SQLiteConnection.CreateFile(m_dataSource);
            DbProviderFactory factory = SQLiteFactory.Instance;
            using (DbConnection conn = factory.CreateConnection())
            {
                // Create DB
                conn.ConnectionString = "Data Source=" + m_dataSource;
                conn.Open();
                // Create Table
                string sql = "create table [aa] ([id] INTEGER PRIMARY KEY, [s] TEXT COLLATE NOCASE)";
                DbCommand cmd = conn.CreateCommand();
                cmd.Connection = conn;
                cmd.CommandText = sql;
                cmd.ExecuteNonQuery();
            }



Reference:
http://hirocat.pixnet.net/blog/post/40514692-%E5%A6%82%E4%BD%95%E9%AB%98%E6%95%88%E4%BD%BF%E7%94%A8sqlite-.net-(c%23)