tsteward Well-Known Member Licensed User Longtime User Apr 28, 2008 #1 How can I find out if a table exists in my sl3 database without it throwing up a window? Thanks Tony
Erel B4X founder Staff member Licensed User Longtime User Apr 28, 2008 #2 You can use the sqlite_master table: B4X: cmd.CommandText = "SELECT COUNT(name) FROM sqlite_master WHERE type = 'table' and name = 'TableYouAreSearchingFor'" Reader.Value = cmd.ExecuteReader If reader.GetValue(0) > 0 Then ... End If Reader.Close
You can use the sqlite_master table: B4X: cmd.CommandText = "SELECT COUNT(name) FROM sqlite_master WHERE type = 'table' and name = 'TableYouAreSearchingFor'" Reader.Value = cmd.ExecuteReader If reader.GetValue(0) > 0 Then ... End If Reader.Close
tsteward Well-Known Member Licensed User Longtime User May 2, 2008 #3 Thanks Erel that works a treat. Why can I find info like that as I wish to learn not just ask questions? Also What is the best method for testing if a record exists. such as WHERE 'ID' = Smith Thanks Heaps
Thanks Erel that works a treat. Why can I find info like that as I wish to learn not just ask questions? Also What is the best method for testing if a record exists. such as WHERE 'ID' = Smith Thanks Heaps
Erel B4X founder Staff member Licensed User Longtime User May 2, 2008 #4 The best source of SQLite information is: www.sqlite.org You can use COUNT to check if more than 0 records were returned (similar to my previous query).
The best source of SQLite information is: www.sqlite.org You can use COUNT to check if more than 0 records were returned (similar to my previous query).