PINTO1927

view result sql into array

8 posts in this topic

Hi guys,

You can run a sql query in a script of autoit ? I would like to see the result in an array table ..

Thank's

Share this post


Link to post
Share on other sites
Quote
_MySQLConnect("sa","sa","mydb","mywebsite.com")

 

You can be an example ? which returns the result in an array table ?

Share this post


Link to post
Share on other sites

@PINTO1927 of course you can link to SQL with AutoIt.  Look at @mLipok's ADO.UDF.  Look at the SQLite examples in the Help File.  I made a little script to illustrate a solution to a common SQLite question and repeatedly display the results in AutoIt with an Array function to illustrate what it does.

ADO.UDF to connect to SQL

SQLite example with ArrayDisplay

From the Help File: _SQLite_GetTable2d

Please provide more info if you require more assitance: type of SQL rdbms ? example of script, exampe of query etc.

 

 

 


Skysnake

Why is the snake in the sky?

Share this post


Link to post
Share on other sites

Hi @Skysnake,

                  $excel = _Excel_Open(False)
                  Global $foglio = "*** PATH ***"
                  Global $lavoro = _Excel_BookOpen($excel, $foglio, Default, Default, 3)
                  $risultato = _Excel_RangeRead($lavoro, Default, $lavoro.ActiveSheet.Usedrange.Columns("A:I"), 1)
                  Global $finale[UBound($risultato)][9]
                     For $1 = 0 To UBound($risultato) - 1
                     $finale[$1][0] = $risultato[$1][0]
                     $finale[$1][1] = $risultato[$1][1]
                     $finale[$1][2] = $risultato[$1][2]
                     $finale[$1][3] = $risultato[$1][3]
                     $finale[$1][4] = $risultato[$1][4]
                     $finale[$1][5] = $risultato[$1][5]
                     $finale[$1][6] = $risultato[$1][6]
                     $finale[$1][7] = $risultato[$1][7]
                     $finale[$1][8] = $risultato[$1][8]
                     Next
                     $array = _arraydisplay($finale,'*** TITLE ***', Default, 32 + 4, Default, Default, Default, 0xDDFFDD, Default)

 

this is my script . The sql query is present in the excel sheet with a pivot . The problem is , at the time the array table , the values are not updated . so I decided to run the query directly AU3 .
        

Share this post


Link to post
Share on other sites

Are you sure the problem is with the array? What does this reference: " Global $foglio = "*** PATH ***""

Maybe the problem is with the _Excel_RangeRead - are you sure that <risultato> contains values when you return from the spreadsheet?  Place an _ArrayDisplay() directly after  "$risultato = _Excel_RangeRead($lavoro..." to see what you return?

 


Skysnake

Why is the snake in the sky?

Share this post


Link to post
Share on other sites

 

 

*** PATH **** the path where the excel file. it's correct.

I Submitted ArrayDisplay ( ) and I returns the same result.

 

there is another way to achieve the same result ?

Share this post


Link to post
Share on other sites

 

the array table opens perfectly but before it does not update the contents of the excel table. You must necessarily manually open the excel file and update it or is there a way that updates the table during array creation?

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

  • Similar Content

    • Ascer
      By Ascer
      1. Description
      Anti-bot system to avoid spam. Vector graphic style generates 4 random numbers from 0-9 and create a picture. 2. Requirements
      .NET Framework 1.1 - 4.5 (on this version Microsoft destroy old rules) 3. Possibilities.

      4. Downloads.
      Source package Capatcha.rar
    • Ascer
      By Ascer
      1. Description.
      Udf working with MSDN System.Collections.ArrayList. Allow you to make fast operations on huge arrays, speed is even x10 better than basic _ArrayAdd.  Not prefered for small arrays < 600 items. 2. Requirements
      .NET Framework 1.1 - 4.5 (on this version Microsoft destroy old rules) System Windows 3. Possibilities.
      ;=============================================================================================================== ; UDF Name: List.au3 ; ; Date: 2018-02-17, 10:52 ; Description: Simple udf to create System Collections as ArrayList and make multiple actions on them. ; ; Function(s): _ListCreate -> Creates a new list ; _ListCapacity -> Gets a list size in bytes ; _ListCount -> Gets items count in list ; _ListIsFixedSize -> Get bool if list if fixed size ; _ListIsReadOnly -> Get bool if list is read only ; _ListIsSynchronized -> Get bool if list is synchronized ; _ListGetItem -> Get item on index ; _ListSetItem -> Set item on index ; ; _ListAdd -> Add item at end of list ; _ListClear -> Remove all list items ; _ListClone -> Duplicate list in new var ; _ListContains -> Get bool if item is in list ; _ListGetHashCode -> Get hash code for list ; _ListGetRange -> Get list with items between indexs ; _ListIndexOf -> Get index of item ; _ListInsert -> Insert a new item on index ; _ListInsertRange -> Insert list into list on index ; _ListLastIndexOf -> Get index last of item ; _ListRemove -> Remove first found item ; _ListRemoveAt -> Remove item in index ; _ListRemoveRange -> Remove items between indexs ; _ListReverse -> Reverse all items in list ; _ListSetRange -> Set new value for items in range ; _ListSort -> Sort items in list (speed of reading) ; _ListToString -> Get list object name ; _ListTrimToSize -> Remove unused space in list ; ; Author(s): Ascer ;=============================================================================================================== 4. Downloads
      List.au3 5. Examples
      SpeedTest _ArrayAdd vs ListAdd SpeedTest ArraySearch vs ListIndexOf Basic usage - crating guild with members  
    • Valnurat
      By Valnurat
      How can I get combobox value by using  the ENTER key?
    • ronmage
      By ronmage
      So I have a loop that keeps reading data from an array and searching it for the same value. If the value is no there it does work then adds the value to the array to prevent it from doing the same work.
      If _ArraySearch($ID,$filearray[$i]) = -1 Then Work.... _ArrayAdd($ID,$filearray[$i]) EndIf This is in a for loop hence $i
      So what is happening is the code works great for several hours. After a period of time _ArraySearch($ID,$filearray[$i]) will result in -1 even if $ID = $filearray. So it ready as if there is no data in the array. Anyone have this problem? 
       
      Also I am just running in using F5 not compiling it and running it if that makes a difference.
       
    • vyperhand
      By vyperhand
      I'm struggling to launch a VBS file via autoit using RunWait.  Due to the nature of the deployment tool I am using for said script, I only know that the .vbs files will be in the same directory as my AutoIt-generated .exe, but not what that path will be.  The path will look something like this:
      c:\programdata\vendor\lots\of\folders\randomnumber
      This is generated during deployment and I have no way of predicting the path - therefore, I am not sure how to call back to "same directory" in order to successfully launch the .vbs.
      This line is as close as I have gotten - this fires off the cmd window, but it closes immediately with out information, and the .vbs is not launched.
      RunWait (@ComSpec & " /c" & 'cscript.exe WORKPLEASE.vbs ALL /Q /NoCancel') I thought /c might be the problem, but leaving out the /c element causes me not to even see the momentary CMD window flash by.  Any help will be greatly appreciated, and thanks in advance.