Sign in to follow this  
Followers 0
mmahima

AutoIt retrieving wrong value from Data Base

7 posts in this topic

When i try to execute the following statements in autoit, it is displaying wrong results, could any one help.

$sqlCon = objCreate("ADODB.Connection")

$objRecordSet = ObjCreate("ADODB.RecordSet")

$sqlCon.Open("Provider='IBMDA400';Data Source = '10.0.1.25';User Id='USERNAME'; password='Password';")

$oRs = $sqlCon.Execute("select * FROM ccdata.rcmast where MSACT# = '8217'")

MSGBOX(0,"",$oRs.Fields("MSACT#").value)

Share this post


Link to post
Share on other sites



When i try to execute the following statements in autoit, it is displaying wrong results, could any one help.

$sqlCon = objCreate("ADODB.Connection")

$objRecordSet = ObjCreate("ADODB.RecordSet")

$sqlCon.Open("Provider='IBMDA400';Data Source = '10.0.1.25';User Id='USERNAME'; password='Password';")

$oRs = $sqlCon.Execute("select * FROM ccdata.rcmast where MSACT# = '8217'")

MSGBOX(0,"",$oRs.Fields("MSACT#").value)

What result are you getting and what are you expecting/should you be getting?

Share this post


Link to post
Share on other sites

What result are you getting and what are you expecting/should you be getting?

I am getting some unknown results, the expected should be 8217

Share this post


Link to post
Share on other sites

I am getting some unknown results, the expected should be 8217

By "unknown results" do you mean a proper result, just not one you recognize from your database.

Or do you mean garbage or an error?

Share this post


Link to post
Share on other sites

By "unknown results" do you mean a proper result, just not one you recognize from your database.

Or do you mean garbage or an error?

it is returning a wrong number other than the one which expected

Share this post


Link to post
Share on other sites

it is returning a wrong number other than the one which expected

Can you use another SQL query tool (there are plenty hanging around for free) and try to look at the recordset returned. It could help you to understand what's going on with your query. Indeed it looks strange but seems rather an SQL than AutoIt thing.


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

Can you use another SQL query tool (there are plenty hanging around for free) and try to look at the recordset returned. It could help you to understand what's going on with your query. Indeed it looks strange but seems rather an SQL than AutoIt thing.

I used VBsedit and AutoIt.

Vbsedit is retrieving correct values, where as AutoIt is retrieving wrong values

The following is the VBsedit code, which is retrieving correct values

Set sqlCon = CreateObject("ADODB.Connection")

Set objRecordSet = CreateObject("ADODB.Recordset")

sqlCon.Open("Provider='IBMDA400';Data Source='10.0.1.25';User Id='r2k2gui4';password='r2k2gui4';")

'Set oRs = sqlCon.Execute ("SELECT * FROM CCDATA.RCMAST WHERE MSACT# = '8216'")

'MsgBox(oRs.Fields("MSFRST").value)

'MsgBox(oRs.Fields("MSDOWN").value)

'Set oRs = sqlCon.Execute ("SELECT * from CCDATA.CCPHONE WHERE PHACT# ='8216'")

'MsgBox(oRs.Fields("PHPHN#").value)

'oRs.MoveNext

'MsgBox(oRs.Fields("PHPHN#").value)

'Set oRs = sqlCon.Execute ("SELECT MSACT#, MSFNM, MSIDESC, MSOACT# FROM CCDATA.RCMAST WHERE msssn = '587533937'")

'MsgBox(oRs.Fields("MSACT#").value)

Set oRs = sqlCon.Execute ("SELECT MSACT#, MSFNM, MSIDESC, MSOACT# FROM CCDATA.RCMAST WHERE MSACT# = '960605650'")

MsgBox(oRs.Fields("MSACT#").value)

whereas the following is AutoIt code that is retrieving wrong values

$sqlCon = ObjCreate('ADODB.Connection')

$objRecordSet = ObjCreate("ADODB.Recordset")

$sqlCon.Open("Provider='IBMDA400';Data Source='10.0.1.25';User Id='r2k2gui4';password='r2k2gui4';")

;~ $oRs = $sqlCon.Execute ("SELECT * FROM CCDATA.RCMAST WHERE MSACT# = '8216'")

;~ MsgBox(0,"",$oRs.Fields("MSFRST").value) ;Displaying wrong date values 20081100 in place of 20081101

;~ MsgBox(0,"",$oRs.Fields("MSDOWN").value)

;~ $oRs = $sqlCon.Execute ("SELECT * from CCDATA.CCPHONE WHERE PHACT# ='8216'")

;~ MsgBox(0,"",$oRs.Fields("PHPHN#").value)

;~ $oRs.MoveNext

;~ MsgBox(0,"",$oRs.Fields("PHPHN#").value) ;Displaying wrong phone number

;~ $oRs = $sqlCon.Execute ("SELECT MSACT#, MSFNM, MSIDESC, MSOACT# FROM CCDATA.RCMAST WHERE msssn = '587533937'")

;~ MsgBox(0,"",$oRs.Fields("MSACT#").value) ;Displaying 960605632 which is wrong value

$oRs = $sqlCon.Execute ("SELECT MSACT#, MSFNM, MSIDESC, MSOACT# FROM CCDATA.RCMAST WHERE MSACT# = '960605650'")

MsgBox(0,"",$oRs.Fields("MSACT#").value) ;Displaying 960605632 which is wrong value

$oRs = 0

$sqlCon = 0

$objRecordSet = 0

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