Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

SQL Table Exists?

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-28-2008, 10:07 AM
Basic4ppc Veteran
 
Join Date: Apr 2008
Location: Gosford NSW Australia
Posts: 223
Send a message via MSN to tsteward
Default SQL Table Exists?

How can I find out if a table exists in my sl3 database without it throwing up a window?

Thanks
Tony
Reply With Quote
  #2 (permalink)  
Old 04-28-2008, 11:18 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

You can use the sqlite_master table:
Code:
    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
Reply With Quote
  #3 (permalink)  
Old 05-02-2008, 12:13 PM
Basic4ppc Veteran
 
Join Date: Apr 2008
Location: Gosford NSW Australia
Posts: 223
Send a message via MSN to tsteward
Default

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
Reply With Quote
  #4 (permalink)  
Old 05-02-2008, 12:18 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,733
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

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).
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking if registry key exists? N1c0_ds Questions (Windows Mobile) 3 10-21-2008 05:30 AM
Retrieve table filter from the filtered table? LineCutter Questions (Windows Mobile) 1 09-08-2008 06:20 AM
How can I know if an object exists? jesb4ppc Questions (Windows Mobile) 7 05-20-2008 10:57 AM


All times are GMT. The time now is 09:21 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0