Search this site:

2008-12-30

Check if datablase table exists


I am recently working with SQLite database and I was stuck with a very simple task: writing a function to create a table, existing table should be dropped. In other database engines this can be achieved using a simple CREATE OR REPLACE TABLE statement but this is not supported in current version of SQLite. Therefore I need to check the existence of a table before running the CREATE TABLE statement, but how?

Having a simple Google search, I got the clue at here: using the DbConnection.GetSchema() method.

Here is the complete code:

public static bool IsTableExists(SQLiteConnection conn, string table_name)
{
return conn.GetSchema("Tables").Select("Table_Name = '" + table_name + "'").Length > 0;
}


Since this is a method defined in ADO standard, so probably it will work for those ADO implementations of other database engine. (Not tested)

2008-12-29

Win32 API Tracing Software


My friend has recommended a software to me for tracing Win32 API call of an executable. Seems that it can also track file and Registry access like Filemon and Regmon (or the Process Monitor) of Windows Sysinternals. Haven't tried it out yet, record here for future reference.

TracePlus/Win32
http://www.sstinc.com/windows.html

Disclaimer

ALL CONTENTS AND INFORMATION IN THIS WEB SITE ARE PROVIDED "AS IT" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED. THE ACCURACY AND AVAILABILITY OF THE CONTENTS, INFORMATION AND THE WEB SITE ITSELF ARE NOT GUARANTEED. THE AUTHOR TAKES NO RESPONSIBILITIES ON ANY COSTS OR DAMAGES (DIRECT OR INDIRECT) ARISING OUT OF OR IN CONNECTION WITH THE ACCESS, USAGE OR INABILITY OF USAGE OF THIS WEB SITE.