stormlolz

Query result

6 posts in this topic

Hello,

I need help for my script... I'm lost..

 

I make a SQL request on my Acces DB, ok it's running and my result is $RS1

$query_logo_niveau = "SELECT logo.niveau FROM logo where logo.num_col = '" & Guictrlread($numcol) & "';"



         $AdoCon2 = ObjCreate("ADODB.Recordset")
         $AdoCon2.ActiveConnection = $AdoCon
         $AdoCon2.Open($query_logo_niveau)
         $RS2 = $AdoCon2.getstring()

MsgBox(0, "result $RS2", $RS2)
FileWrite("rs2.txt", $RS2)

 

But my result $RS1 are :

in txt file : " 6  5  7  3  2  1"

in msgbox : (see png join)

 

I want to set each different value of my results query in string/variable

how can i do ?

 

Thank you so much

Sorry for my english

Capture.PNG

rs2.txt

Share this post


Link to post
Share on other sites



Something like this maybe?

#include <Array.au3>
$query_logo_niveau = "SELECT logo.niveau FROM logo where logo.num_col = '" & Guictrlread($numcol) & "';"
    $AdoCon2 = ObjCreate("ADODB.Recordset")
    $AdoCon2.ActiveConnection = $AdoCon
    $AdoCon2.Open($query_logo_niveau)
    $RS2 = $AdoCon2.getstring()
    $aRS2 = StringSplit($RS2, @CR)
_ArrayDisplay($aRS2)

 

1 person likes this

Share this post


Link to post
Share on other sites

Hello, Thank you for the answer

 

And I have my results with :

$aRS2[1]

$aRS2[2]

 

... ?

 

What it's the row 0, $aRS2[0] which have value 7 ?

 

Capture2.PNG

Share this post


Link to post
Share on other sites

The number of rows, so you can then use it in something like

For $x = 1 To $aRS2[0]
    ConsoleWrite($aRS2[$x] & @CRLF)
Next

 

Share this post


Link to post
Share on other sites

You probably should use, StringStripWS with Flag 7 to remove whitespace at the beginning and end of the string, so that you don't have the blank last row.

$aRS2 = StringSplit(StringStripWS($RS2, 7), @CR)

Share this post


Link to post
Share on other sites

Thank you I have my result without space

 

I don't know how work Consolewrite / Consoleread, but thank you so !

Capture3.PNG

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