Jump to content

Only Object-type variables allowed in a "With" statement.


oshaker
 Share

Recommended Posts

#include "mysql.au3"

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

Dim $var, $sql

$sql = _MySQLConnect("UserName","Password","DB_Name","DB_IP_Address")
$var = _Query($sql,"SELECT user.user_id, user.firstname,user.username,course.code FROM dokeos_main.user ,dokeos_main.course_rel_user, dokeos_main.course where user.user_id=course_rel_user.user_id and course_rel_user.course_code=course.code" )

FileOpen ( "c:\test.txt", 130)

With $var
While NOT .EOF
FileWriteLine("c:\test.txt",.Fields("username").value & "," & .Fields("firstname").value & .Fields("code").value & @CRLF)
.MoveNext
WEnd
EndWith
_MySQLEnd($sql)


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 _
            )
exit
EndFunc

This gives me:

Only Object-type variables allowed in a "With" statement.

With $var

With ^ ERROR

How can I fix it?

Link to comment
Share on other sites

From memory that function returns an array. So For...Next will do the job. See what the function returns first though. Should be some documentation in MySQL.au3.

Cheers,

Brett

Link to comment
Share on other sites

  • 3 weeks later...

I am unable to replicate but some observations. You called ObjCreate like 10 times in the one function. There was no need for it and I opened the object at the start of the script. Other than that there were no real problems I could see (or test).

Please grab the full version of SciTE and run it from there. Past the console output, so at least we know where the error is coming from.

Cheers,

Brett

Link to comment
Share on other sites

Which one? There are 4 different occurrences of it? What does that error mean in ENGLISH? Have you Googled the error and the error code?

Edited by BrettF
Link to comment
Share on other sites

The error is that the "MSCommLib.MSComm" object is not being created.

If this is working on your PC but not on anther PC then I would suspect that the PC on which it is not working does not have "MSCommLib.MSComm" installed. I don't believe that MScomm is a standard component of windows. check if this file exists on the PC with the problem "C:\WINDOWS\system32\MSCOMM32.OCX".

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

  • 1 month later...

It happenes to me as well but on random computers in our company. Just now one computer was failing to connect on line

$Objconn.open in _MySQLConnect function

and that Comerror handler failed to catch it although it works in other cases! Is it because I compiled it with Autoit 3.3.0.0? Unfortunatelly I restarted the computer and then it works again without error! So I will have to wait when it happens next time :-\

Edited by LoWang
Link to comment
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
 Share

  • Recently Browsing   0 members

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