Jump to content

Recommended Posts

Posted

i have a script where i want to use if function to do something but i don't know how to use it, can anybody help me?

here's the code:

;  $conn is a variable that opens a connection to the database
;  $rs is a ADODB Object
;=============================

$Query = "Select * from table1"
$rs = $conn.Execute ($Query)
$array = $rs.GetRows()

the problem is that when the $rs variable is empty the script stops.

i want to know how to check if this variable is empty and holds no data

Posted (edited)

ok i will give it a try now, but can i write:

if $rs not = "" then

how can i make it continue when it's not null.

thank you again

i will correct you.

If not $rs = "" then

or

If $rs Then
Edited by monoscout999
Posted (edited)

thank you for the correction,

i tried the previous one but it didn't work for me the script stopped as well, i hope you could bear with me a while

here the code i wrote:

if $rs = "" Then
    ShowInfo("Found No Data..", "500", "0")  ;show a message using another function
Else
    $array = $rs.GetRows()

it stopped at $rs.GetRows()

is there any thing else i can try?

Edited by eternityseeker
Posted

$rsis a rowset object, not an elementary AutoIt variable.

You can test for an empty rowset easily with:

$iNumberOfRows = $rs.RecordCount

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)

Posted

thank you for helping me, i tried it and the :

$iNumberOfRows = $rs.RecordCount

always gives result = -1 meaning that the "$iNumberOfRows" is equal -1 when $rs is empty and when it is full

i'm still trying to find a way to check when it's empty | with your help of course :)

Posted

i tried the "VarGetType" function as i saw on another topic in the forum, and i found that the variable $rs is an "object"

but i didn't find how to check if it's empty on the forum

Posted

I found it ..

I found it

i found it in another topic, the topic was discussing something bigger than just my case but someone wrote it and i tried it an it worked.

here it is:

if not $rs.EOF then

the secret is the "EOF" that was placed after the variable i checks if it's empty.

thank you all.

i don't know why when i write a dot "." the available parameters aren't shown automatically, i know some of them are shown but not everything.

but a great scripting language very very very useful :)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...