Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


SQL Table Exists?


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-28-2008, 11:07 AM
Senior Member
 
Join Date: Apr 2008
Location: Gosford NSW Australia
Posts: 146
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, 12:18 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,334
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, 01:13 PM
Senior Member
 
Join Date: Apr 2008
Location: Gosford NSW Australia
Posts: 146
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, 01:18 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,334
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 On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 04:15 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0