October 09, 2024, 04:24:36 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Problem with dbListTables

Started by billhsln, May 17, 2010, 09:08:02 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

billhsln

It seems that dbListTables also returns stored SQL Queries.  Is there some way to limit it to ONLY files.

Thanks,
Bill
When all else fails, get a bigger hammer.

LarryMc

I've never seen a "stored query" so I cn't help you.

What does the string look like that is returned?

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

After looking at the source code for the command it appears the function, as coded, returns everything.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

billhsln

It returns the name of the stored query.  They are just file names.  I have a way to limit which tables are being displayed (first table is called 'cards'), maybe I will add a table called '999zzz' and when I get to that Table Name I will stop displaying the table names.

Bill
When all else fails, get a bigger hammer.

LarryMc

This might be something Larry can fix when he looks at the Db functions for V2.0

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

billhsln

I can create a smaller sample and send it, if needed.  I would send the original, but it is 4.7 Meg.  Lots of info to keep track of Pokemon cards.

Bill
When all else fails, get a bigger hammer.

LarryMc

Post a example with what you would like to do; for the record.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

billhsln

At this point the database has already been attached.

OPENWINDOW w3,0,0,200,230,0x80C80080,d1,"Available Data Base Files",&w3_handler
CONTROL w3,@LISTVIEW,"",5,5,180,190,@vscroll|0x50000001|@border,W3_L1
CONTROLCMD w3,W3_L1,@LVINSERTCOLUMN,0,"File"
CONTROLCMD w3,W3_L1,@LVINSERTCOLUMN,1," "
pTables = dbListTables(pDB)
IF pTables <> NULL
ti = 0
lvi = -1
FOR pTemp = EACH pTables as STRING
IF #pTemp = "zzzz9999" THEN ti = 0
IF ti = 1
lvi++
CONTROLCMD w3,W3_L1,@LVINSERTITEM,lvi,#pTemp
ENDIF
IF #pTemp = "cards" THEN ti = 1
NEXT
ListRemoveAll(pTables,TRUE)
Else
Print "No Tables to list"
ENDIF
' Set Listview field to max needed size
CONTROLCMD w3,W3_L1,@LVSETCOLWIDTH,0,-1
' Set last field (which is empty) to take up all the rest of the listview
CONTROLCMD w3,W3_L1,@LVSETCOLWIDTH,1,-2


Logic to process and close w3 is in handler.

Hope that shows what I am doing.

#pTemp = cards (first data file I create)
#pTemp = zzzz9999 (last data file, just so I can stop displaying)

This way I only show Tables and not Queries.

Bill
When all else fails, get a bigger hammer.

billhsln

More strangeness....modified code to display more info and now it does NOT display Queries....

Revised code:


OPENWINDOW w3,0,0,200,230,0x80C80080,d1,"Available Data Base Files",&w3_handler
CONTROL w3,@LISTVIEW,"",5,5,180,190,@vscroll|0x50000001|@border,W3_L1
CONTROLCMD w3,W3_L1,@LVINSERTCOLUMN,0,"File"
CONTROLCMD w3,W3_L1,@LVINSERTCOLUMN,1,"Recs"
CONTROLCMD w3,W3_L1,@LVINSERTCOLUMN,2,"Cols"
CONTROLCMD w3,W3_L1,@LVINSERTCOLUMN,3," "
pTables = dbListTables(pDB)
IF pTables <> NULL
ti = 0
lvi = -1
FOR pTemp = EACH pTables as STRING
IF mid$(#pTemp,1,4) = "MSys"
ti = 0
ELSE
IF #pTemp = "cards"
ti = 0
ELSE
ti = 1
ENDIF
ENDIF
IF ti = 1
lvi++
IF dbCardinality(pDB,#pTemp) > 0 THEN CONTROLCMD w3,W3_L1,@LVINSERTITEM,lvi,#pTemp
CONTROLCMD w3,W3_L1,@LVSETTEXT,lvi,1,STR$(dbCardinality(pDB,#pTemp))
pCol = dbListColumns(pdb,#pTemp)
IF pCol <> NULL
tmp = ""
FOR pColT = EACH pCol as STRING
tmp += #pColT + ","
NEXT
PRINT
ListRemoveAll(pCol,TRUE)
ENDIF
CONTROLCMD w3,W3_L1,@LVSETTEXT,lvi,2,tmp
ENDIF
NEXT
ListRemoveAll(pTables,TRUE)
Else
lvi++
CONTROLCMD w3,W3_L1,@LVINSERTITEM,lvi,"No Tables Available"
ENDIF
CONTROLCMD w3,W3_L1,@LVSETCOLWIDTH,0,-1
CONTROLCMD w3,W3_L1,@LVSETCOLWIDTH,1,-1
CONTROLCMD w3,W3_L1,@LVSETCOLWIDTH,2,-1
CONTROLCMD w3,W3_L1,@LVSETCOLWIDTH,3,-2


I have it NOT display the MSys files and not cards, other than that it should display every thing.  But now it only displays Tables and not Queries.

Strange...

Bill
When all else fails, get a bigger hammer.