skrbx Posted May 28, 2014 Share Posted May 28, 2014 (edited) Hello to all, I am using Autoit since like a 2 years ago but i am not very much like "forum guy" thats why i haven't registered until now. Ye so i have have this problem stuck in my head very hard. After numberous of houts trying and searching how to Display the result of sql (in my case sqlite) query to a gui (listview) without result, i give up and came here to ask for a help. So here is "my" (not mine, i found it somewhe here on the forum) code which shall do what i need: Func sSQLite_GetDisplayArray2d($hDB, $sql, ByRef $rows, ByRef $nrows, ByRef $ncols, $Title = 'TITLEX') Local $rtn = _SQLite_GetTable2d($hDB, $sql, $result, $nrows, $ncols) If Not @error Then If $rtn = $SQLITE_OK And $ncols > 0 Then Local $Header = "Row" For $i = 0 to $ncols - 1 $Header &= '|' & $result[2][$i] Next _ArrayDelete($result, 0) _ArrayDisplay($result, $Title, -1, 0, '', '', $Header) ;_ArrayDisplay( EndIf EndIf Return (SetError(@error, 0, $rtn)) EndFunc And here is the reference: sSQLite_GetDisplayArray2d($dbn, "Select * from TABLE where id >0", $iRows, $nRows, $iColumns) Basically when i call the function, there is a Gui poping up but no results in it: So yea, if you have any clue or idea or anything please tell me. Thanks in advance. Best Regards! Edited May 28, 2014 by skrbx Link to comment Share on other sites More sharing options...
jchd Posted May 28, 2014 Share Posted May 28, 2014 Are you sure that the table named "table" (an unfortunate colliding name by the way, best avoided) actually contains 3 data rows containing something else than blanks or NULLs? You can use SQLite Expert freeware to examine the DB and check that it constains what you expect to find. Also I regard $Header &= '|' & $result[2][$i] as doubtful: how come does the last row contain column names? Finally are you sure you want those parameters passed to _ArrayDisplay? -1 for the display range (???), 0 for flag (that is the default), '' for header (I suspect this is not what you want) and $header for colmun width (???). This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
skrbx Posted May 28, 2014 Author Share Posted May 28, 2014 Thank you for your answer. 1) TABLE is just for debugging it will be changed with variable which will read the DB name from config file. 2) Thank you for suggesting but i need this for a program i am currently working on. 3) About $Header &= '|' & $result[2][$i], i am not quite sure how this supposed to look like, and if i have to be honest i am not sure what exactly does... 4) And finally about _ArrayDisplay, i am sure that i have tried quite few different "settings" with no result. As i said the code was posted somewhere here i just "changed it a bit" to match with my "code". PS: As i also need to be able to select and copy (no paste) the records and also to make the GUI scalable, so.. is this a way worth to struggle with or there is better way to accomplish this. Again thank you in advance. Link to comment Share on other sites More sharing options...
jchd Posted May 28, 2014 Share Posted May 28, 2014 OK. So give me some time to make up a short and simple example use. In the meantime and if the DB you already have doesn't contain personal data and provided it's small enough, can you post it or provide a download link from some ad-free repository, so I can have a look at it and stop guessing about this one. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
jchd Posted May 28, 2014 Share Posted May 28, 2014 Here is a starter skeleton on which you can build: expandcollapse popup#include <Array.au3> #include <SQLite.au3> #include <SQLite.dll.au3> _SQLite_Startup() Local $hDB = _SQLite_Open() ; no filename given ==> temporary memory-based DB _SQLite_Exec($hDB, "create table Sports (" & _ "ID integer primary key autoincrement, " & _ "Sport char collate nocase, " & _ "Team char, " & _ "Indoor char);" & _ "create unique index uixSport on Sports (Sport);") _SQLite_Exec($hDB, "insert into Sports (sport, team, indoor) values " & _ "('Football', 'Y', 'N'), " & _ "('Trampolining', 'N', 'Y'), " & _ "('Soccer', 'Y', 'N'), " & _ "('Table tennis', 'N', 'Y'), " & _ "('Shot put', 'N', 'N'), " & _ "('Pole vault', 'N', 'N'), " & _ "('Rugby', 'Y', 'N'), " & _ "('Basketball', 'Y', 'Y'), " & _ "('Marathon', 'N', 'N'), " & _ "('Boxing', 'N', 'Y'), " & _ "('Baseball', 'Y', 'N'), " & _ "('Heptathlon', 'N', 'N'), " & _ "('Javelin', 'N', 'N'), " & _ "('Horseball', 'Y', 'N'), " & _ "('Golf', 'N', 'N'), " & _ "('Skydive', 'Y', 'N'), " & _ "('Hockey', 'Y', 'Y'), " & _ "('Squash', 'N', 'Y'), " & _ "('Sumo', 'N', 'Y'), " & _ "('Badminton', 'N', 'Y'), " & _ "('Beach volley', 'Y', 'N'), " & _ "('Snowboarding', 'N', 'N');") Local $aRows, $iRows, $iCols _SQLite_GetTable2d($hDB, "select * from sports where team like 'n';", $aRows, $iRows, $iCols) _ArrayDisplay($aRows) ; if you want actual DB column names as header, then do Local $sHeader For $i = 0 To $iCols - 1 $sHeader &= $aRows[0][$i] & '|' Next $sHeader = StringTrimRight($sHeader, 1) _ArrayDisplay($aRows, "Individual Sports", "1:", Default, Default, $sHeader) _SQLite_Close($hDB) _SQLite_Shutdown() This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
skrbx Posted May 29, 2014 Author Share Posted May 29, 2014 Awesome Thank you very much!!! All i need to do is to strip the "Row" Column and to make the table bigger. i have tried to add: _ArrayDelete($iCols, 0) but it does not work. About the second thing i assume that i can add something like: GUICtrlSetFont to change the font, but this one does not do the job. Link to comment Share on other sites More sharing options...
jchd Posted May 29, 2014 Share Posted May 29, 2014 (edited) _ArrayDisplay doesn't have such flexibility; This function is designed mainly as a debugging aid so it doesn't offer all the bells and whistles that a home-made listview may use. For instance there is no provision to remove the Row column (albeit I feel there should be such a switch parameter). Either build your own GUI which you can design exactly as you want, or copy the _ArrayDisplay function from the UDF file, rename it to _MyArrayDisplay and modify it according to your needs. Perhaps that will prove the easiest path but that depends on the interaction(s) you expect to offer in your application. If the goal is only to display some queries like that, making your modified function may be enough. EDIT: thinking again about the issue, you may also find >this post of interest, even if Greencan's code does much more than you probably need (getting more bang for no buck never hurt BTW). Edited May 29, 2014 by jchd skrbx 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
skrbx Posted June 11, 2014 Author Share Posted June 11, 2014 Thank you very much. Sorry for late answer but i've been away for some time. Mark as solved and Close, Thanks! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 11, 2014 Moderators Share Posted June 11, 2014 (edited) skrbx,In the latest v3.3.12.0 release I added a flag to remove the "Row" column from the _ArrayDisplay GUI - why not take a look. M23 Edited June 11, 2014 by Melba23 Typo Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
jchd Posted June 11, 2014 Share Posted June 11, 2014 Ah, I forgot to "piggy-back" this new feature to this thread, where it all came from. My bad. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now