Jump to content

Error connect Access table using Autoit


Recommended Posts

Hello, friends.

Please help to find the mistake in a code.

I try run access from autoit and a result as a string.

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.6.1

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

#include <array.au3>

$dbname = "C:\TRA\TRA_BACKEND.mdb"

$tblname = "T_Cert_Recert"

$objErr = ObjEvent("AutoIt.Error","MyErrFunc")

$query = "SELECT * FROM " & $tblname & " WHERE SAP-NO = 'CN01012'"

Local $title

$adoCon = ObjCreate("ADODB.Connection")

$adoCon.Open('Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\TRA\TRA_BACKEND.mdb') ;Use this line if using MS Access 2003 and lower

$adoRs = ObjCreate ("ADODB.Recordset")

$adoRs.CursorType = 2

$adoRs.LockType = 3

$adoRs.Open ($query, $adoCon)

$title1 = $adoRs.Fields("ICT").value

$adoCon.Close

MsgBox(0,"testing",$title1, 2 )

Func MyErrFunc()

$hexnum=hex($objErr.number,8)

Msgbox(0,"","We intercepted a COM Error!!" & @CRLF & @CRLF & _

"err.description is: " & $objErr.description & @CRLF & _

"err.windescription is: " & $objErr.windescription & @CRLF & _

"err.lastdllerror is: " & $objErr.lastdllerror & @CRLF & _

"err.scriptline is: " & $objErr.scriptline & @CRLF & _

"err.number is: " & $hexnum & @CRLF & _

"err.source is: " & $objErr.source & @CRLF & _

"err.helpfile is: " & $objErr.helpfile & @CRLF & _

"err.helpcontext is: " & $objErr.helpcontext _

)

ConsoleWrite ("We intercepted a COM Error!!" & @CRLF)

ConsoleWrite ("err.description is: " & $objErr.description & @CRLF)

ConsoleWrite ("err.windescription is: " & $objErr.windescription & @CRLF)

ConsoleWrite ("err.lastdllerror is: " & $objErr.lastdllerror & @CRLF)

ConsoleWrite ("err.scriptline is: " & $objErr.scriptline & @CRLF)

ConsoleWrite ("err.number is: " & $hexnum & @CRLF)

ConsoleWrite ("err.source is: " & $objErr.source & @CRLF)

ConsoleWrite ("err.helpfile is: " & $objErr.helpfile & @CRLF)

ConsoleWrite ("err.helpcontext is: " & $objErr.helpcontext & @CRLF)

ConsoleWrite (@CRLF)

SetError(1)

EndFuncpost-62415-0-68076900-1311225386_thumb.j

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

    No registered users viewing this page.

×
×
  • Create New...