Sign in to follow this  
Followers 0
shreeks

How to display data(records) from DB as 2D list using AutoIt ?

4 posts in this topic

Hi,

The following code of mine selects all records from comp_pune table and displays – all columns and data of those respective columns as one single column in output window. But, my aim is to have an output like the one attached as a snapshot. Could someone modify the below code and help me out.

Local $avArray[6][24],$iRows,$iColumns
$iRval = _SQL_GetTable(-1,"select * from comp_pune",$avArray,$iRows,$iColumns)
If $iRval = $SQL_OK then _ArrayDisplay($avArray, "$avArray as a 2D array")

Thank you. In case of details, please feel free to mail me at shreeks@ymail.com <EOM>


Learning is Lifelong!

Share this post


Link to post
Share on other sites



Try this:

Local $avArray  ; don't need to give explicit dimension(s) at all as the call below will (re-)create an array with suitable dimensions
Local$iRows, $iColumns
$iRval = _SQL_GetTable2d(-1,"select * from comp_pune",$avArray,$iRows,$iColumns)
If $iRval = $SQL_OK then _SQLite_Display2DResult($avArray)

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 here
RegExp tutorial: enough to get started
PCRE 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)

Share this post


Link to post
Share on other sites

Try this:

Local $avArray  ; don't need to give explicit dimension(s) at all as the call below will (re-)create an array with suitable dimensions
Local$iRows, $iColumns
$iRval = _SQL_GetTable2d(-1,"select * from comp_pune",$avArray,$iRows,$iColumns)
If $iRval = $SQL_OK then _SQLite_Display2DResult($avArray)

Hi jchd,

Thanks for your reply. It works fine though its a small tune up. But, its a timely help. Thanks folk.


Learning is Lifelong!

Share this post


Link to post
Share on other sites

Friends,

My aim is to connect to a DB2 database, execute a query and retrieve a result using AutoIt script. I've already automated the connect to a SQL Server database, execute a query and retrieve a result using AutoIt script. Below is the latter code for your concern.

#cs ----------------------------------------------------------------------------
Script Function: AutoIt code to connect to SQL Server DB, execute a query and retreive a data.
#ce ----------------------------------------------------------------------------
#include <_sql.au3>
#include <array.au3>
Opt ("trayIconDebug",1)
_SQL_RegisterErrorHandler() ; register the error handler to prevent hard crash on COM error
$oADODB = _SQL_Startup()
If $oADODB = $SQL_ERROR then Exit Msgbox(0 + 16 +262144,"Error",_SQL_GetErrMsg())
If _sql_Connect(-1,"ctsintcosinb","LPS_March_EAM_2011_02","ams","ams") = $SQL_ERROR then  ; ==> change server, database, user and password to your needs
    Msgbox(0 + 16 +262144,"Error",_SQL_GetErrMsg())
    _SQL_Close()
    Exit
EndIf
Local $avArray,$iRows,$iColumns
$iRval = _SQL_GetTable2D(-1,"select * from comp_pune",$avArray,$iRows,$iColumns) ; ==> Fetch data from comp_pune table
If $iRval = $SQL_OK then _ArrayDisplay($avArray, "Records from comp_pune table")
_SQL_Close()

Now, my query is can I just copy the above code and change the DB credentials ? Is it alone fine to connect to a DB2 database and execute a query ?

If 'changing' the DB credentials is ALONE fine then PFA snap with this post. Could you please tell me where the contents(Alias, Database Type, Driver(JDBC), Database URL, Userid, Password) as stated in this snap has to be re-mapped into your code? Thanks and looking forward for your earliest reply.

post-64194-0-27958100-1304665310_thumb.p


Learning is Lifelong!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0