New topic: Problem with retrieving SQLite Table List
<http://forums.realsoftware.com/viewtopic.php?t=44810> Page 1 of 1 [ 3 posts ] Previous topic | Next topic Author Message tseyfarth Post subject: Problem with retrieving SQLite Table ListPosted: Sun Jul 22, 2012 7:33 pm Joined: Sat Dec 04, 2010 9:14 pm Posts: 660 Hello All, I wrote a class to retrieve all of the tables in the a SQLite Database file. The problem is, the result of the SELECT yields an incorrect table count of 69. When checking the same DB with SQLite Expert Pro, the Table Count is only 42 - which is correct. Looking further into the problem, the tables listed by the query, it appears SOME of them are listed twice and even 3 times. So what is the wrong? Can anyone tell me? Thanks, Tim TableList(0) As modInet.clsTableList RsSQLIteMaster As RecordSet RecordCount As Integer Db As clsSQLWrapper Sub Constructor() TableList(0) = new modInet.clsTableList 'TableList.Remove(1) End Sub Function GetAll() As Int16 'SELECT name FROM sqlite_master 'WHERE type='table' 'ORDER BY name; #if TargetWeb RsSQLIteMaster= Session.db.SQLSelect("SELECT * FROM sqlite_master") if Session.db.Error = true then dbMessage = Session.db.ErrorMessage dbErrorNo = Session.db.ErrorCode Return 0 end if #else 'RsSQLIteMaster=db.SQLSelect("SELECT * FROM sqlite_master ORDER BY tbl_name") RsSQLIteMaster=db.SQLSelect("SELECT * FROM sqlite_master") if db.Error = true then dbMessage=db.ErrorMessage dbErrorNo =db.ErrorCode Return 0 end if #endif RecordCount = RsSQLIteMaster.RecordCount If RecordCount = 1 then 'Tablenames(0) = RsSQLIteMaster.Field("tbl_name").StringValue Elseif RecordCount > 1 then Dim i As Integer = 0 Do Until RsSQLIteMaster.EOF Dim TL As New modInet.clsTableList 'Tablenames(i) = RsSQLIteMaster.Field("tbl_name").StringValue TL.TableName = RsSQLIteMaster.Field("tbl_name").StringValue TableList.Append TL i = i +1 RsSQLIteMaster.MoveNext Loop End if Return RecordCount Exception e as RuntimeException System.DebugLog( "Unknown exception in: clsAlarmZone.getAll") MsgBox("An exception in: clsAlarmZone.getAll " + e.Type + " was caught.") End Function Top DaveS Post subject: Re: Problem with retrieving SQLite Table ListPosted: Sun Jul 22, 2012 7:38 pm Joined: Sun Aug 05, 2007 10:46 am Posts: 3916 Location: San Diego, CA SQLite_master has INDEX information as well... SELECT tbl_name FROM sqlite_master where type='table' just like you have in your COMMENT (but NOT in your code) _________________ Dave Sisemore MacPro, OSX 10.7.3 RB2011r3 Note : I am not interested in any solutions that involve custom Plug-ins of any kind Top tseyfarth Post subject: Re: Problem with retrieving SQLite Table ListPosted: Sun Jul 22, 2012 7:57 pm Joined: Sat Dec 04, 2010 9:14 pm Posts: 660 Hi Dave, Thank you! That was exactly the problem and fixed it perfectly! Is there also an easy way to get the field list and field type? Thank you again, Tim Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 3 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
